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
weijia/djangoautoconf
djangoautoconf/local_key_manager.py
get_local_key
def get_local_key(module_and_var_name, default_module=None): """ Get local setting for the keys. :param module_and_var_name: for example: admin_account.admin_user, then you need to put admin_account.py in local/local_keys/ and add variable admin_user="real admin username", module_name_and_var_name s...
python
def get_local_key(module_and_var_name, default_module=None): """ Get local setting for the keys. :param module_and_var_name: for example: admin_account.admin_user, then you need to put admin_account.py in local/local_keys/ and add variable admin_user="real admin username", module_name_and_var_name s...
[ "def", "get_local_key", "(", "module_and_var_name", ",", "default_module", "=", "None", ")", ":", "if", "\"-\"", "in", "module_and_var_name", ":", "raise", "ModuleAndVarNameShouldNotHaveDashCharacter", "key_name_module_path", "=", "module_and_var_name", ".", "split", "(",...
Get local setting for the keys. :param module_and_var_name: for example: admin_account.admin_user, then you need to put admin_account.py in local/local_keys/ and add variable admin_user="real admin username", module_name_and_var_name should not contain "-" because :param default_module: If the t...
[ "Get", "local", "setting", "for", "the", "keys", ".", ":", "param", "module_and_var_name", ":", "for", "example", ":", "admin_account", ".", "admin_user", "then", "you", "need", "to", "put", "admin_account", ".", "py", "in", "local", "/", "local_keys", "/", ...
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/local_key_manager.py#L37-L52
train
Get the local key for the given module and variable name.
contains-io/typet
typet/meta.py
metaclass
def metaclass(*metaclasses): # type: (*type) -> Callable[[type], type] """Create the class using all metaclasses. Args: metaclasses: A tuple of metaclasses that will be used to generate and replace a specified class. Returns: A decorator that will recreate the class using t...
python
def metaclass(*metaclasses): # type: (*type) -> Callable[[type], type] """Create the class using all metaclasses. Args: metaclasses: A tuple of metaclasses that will be used to generate and replace a specified class. Returns: A decorator that will recreate the class using t...
[ "def", "metaclass", "(", "*", "metaclasses", ")", ":", "# type: (*type) -> Callable[[type], type]", "def", "_inner", "(", "cls", ")", ":", "# pragma pylint: disable=unused-variable", "metabases", "=", "tuple", "(", "collections", ".", "OrderedDict", "(", "# noqa: F841",...
Create the class using all metaclasses. Args: metaclasses: A tuple of metaclasses that will be used to generate and replace a specified class. Returns: A decorator that will recreate the class using the specified metaclasses.
[ "Create", "the", "class", "using", "all", "metaclasses", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/meta.py#L38-L67
train
A decorator that creates the class using all metaclasses.
projectshift/shift-schema
shiftschema/filters/add_http.py
AddHttp.filter
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context :return:...
python
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context :return:...
[ "def", "filter", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "http", "=", "[", "'http://'", ",", "'https://'", "]", "if", "all", "(", "not", "str", "(", "value", ")", ".", "startswith", "(", "s", "...
Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context :return: filtered value
[ "Filter", "Performs", "value", "filtering", "and", "returns", "filtered", "result", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/filters/add_http.py#L19-L33
train
Filter the value for the current object based on its parent model and context.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
Interventions.changeHS
def changeHS(self): """ Change health system interventions https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#change-health-system Returns: list of HealthSystems together with timestep when they are applied """ health_systems = [] change_hs = self.e...
python
def changeHS(self): """ Change health system interventions https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#change-health-system Returns: list of HealthSystems together with timestep when they are applied """ health_systems = [] change_hs = self.e...
[ "def", "changeHS", "(", "self", ")", ":", "health_systems", "=", "[", "]", "change_hs", "=", "self", ".", "et", ".", "find", "(", "\"changeHS\"", ")", "if", "change_hs", "is", "None", ":", "return", "health_systems", "for", "health_system", "in", "change_h...
Change health system interventions https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#change-health-system Returns: list of HealthSystems together with timestep when they are applied
[ "Change", "health", "system", "interventions", "https", ":", "//", "github", ".", "com", "/", "SwissTPH", "/", "openmalaria", "/", "wiki", "/", "GeneratedSchema32Doc#change", "-", "health", "-", "system", "Returns", ":", "list", "of", "HealthSystems", "together"...
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L182-L194
train
Returns a list of HealthSystems together with timestep when they are applied
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
ITN.anophelesParams
def anophelesParams(self): """ :rtype: AnophelesParams """ list_of_anopheles = [] for anophelesParams in self.itn.findall("anophelesParams"): list_of_anopheles.append(AnophelesParams(anophelesParams)) return list_of_anopheles
python
def anophelesParams(self): """ :rtype: AnophelesParams """ list_of_anopheles = [] for anophelesParams in self.itn.findall("anophelesParams"): list_of_anopheles.append(AnophelesParams(anophelesParams)) return list_of_anopheles
[ "def", "anophelesParams", "(", "self", ")", ":", "list_of_anopheles", "=", "[", "]", "for", "anophelesParams", "in", "self", ".", "itn", ".", "findall", "(", "\"anophelesParams\"", ")", ":", "list_of_anopheles", ".", "append", "(", "AnophelesParams", "(", "ano...
:rtype: AnophelesParams
[ ":", "rtype", ":", "AnophelesParams" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L350-L357
train
returns a list of AnophelesParams
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
ITN.get_attrition_in_years
def get_attrition_in_years(self): """ Function for the Basic UI """ attrition_of_nets = self.itn.find("attritionOfNets") function = attrition_of_nets.attrib["function"] if function != "step": return None L = attrition_of_nets.attrib["L"] return...
python
def get_attrition_in_years(self): """ Function for the Basic UI """ attrition_of_nets = self.itn.find("attritionOfNets") function = attrition_of_nets.attrib["function"] if function != "step": return None L = attrition_of_nets.attrib["L"] return...
[ "def", "get_attrition_in_years", "(", "self", ")", ":", "attrition_of_nets", "=", "self", ".", "itn", ".", "find", "(", "\"attritionOfNets\"", ")", "function", "=", "attrition_of_nets", ".", "attrib", "[", "\"function\"", "]", "if", "function", "!=", "\"step\"",...
Function for the Basic UI
[ "Function", "for", "the", "Basic", "UI" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L374-L383
train
Get the attrition in years for the Basic UI
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
GVI.anophelesParams
def anophelesParams(self): """ :rtype: AnophelesParams """ list_of_anopheles = [] for anophelesParams in self.gvi.findall("anophelesParams"): list_of_anopheles.append(AnophelesParams(anophelesParams)) return list_of_anopheles
python
def anophelesParams(self): """ :rtype: AnophelesParams """ list_of_anopheles = [] for anophelesParams in self.gvi.findall("anophelesParams"): list_of_anopheles.append(AnophelesParams(anophelesParams)) return list_of_anopheles
[ "def", "anophelesParams", "(", "self", ")", ":", "list_of_anopheles", "=", "[", "]", "for", "anophelesParams", "in", "self", ".", "gvi", ".", "findall", "(", "\"anophelesParams\"", ")", ":", "list_of_anopheles", ".", "append", "(", "AnophelesParams", "(", "ano...
:rtype: AnophelesParams
[ ":", "rtype", ":", "AnophelesParams" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L516-L523
train
returns a list of AnophelesParams
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
HumanInterventions.add
def add(self, intervention, id=None): """ Add an intervention to intervention/human section. intervention is either ElementTree or xml snippet """ if self.et is None: return assert isinstance(intervention, six.string_types) et = ElementTree.fromstring...
python
def add(self, intervention, id=None): """ Add an intervention to intervention/human section. intervention is either ElementTree or xml snippet """ if self.et is None: return assert isinstance(intervention, six.string_types) et = ElementTree.fromstring...
[ "def", "add", "(", "self", ",", "intervention", ",", "id", "=", "None", ")", ":", "if", "self", ".", "et", "is", "None", ":", "return", "assert", "isinstance", "(", "intervention", ",", "six", ".", "string_types", ")", "et", "=", "ElementTree", ".", ...
Add an intervention to intervention/human section. intervention is either ElementTree or xml snippet
[ "Add", "an", "intervention", "to", "intervention", "/", "human", "section", ".", "intervention", "is", "either", "ElementTree", "or", "xml", "snippet" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L690-L720
train
Add an intervention to the intervention section.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
VectorPopIntervention.anopheles
def anopheles(self): """ :rtype: Anopheles """ list_of_anopheles = [] desc = self.et.find("description") if desc is not None: for anopheles in desc.findall("anopheles"): list_of_anopheles.append(Anopheles(anopheles)) return list_of_an...
python
def anopheles(self): """ :rtype: Anopheles """ list_of_anopheles = [] desc = self.et.find("description") if desc is not None: for anopheles in desc.findall("anopheles"): list_of_anopheles.append(Anopheles(anopheles)) return list_of_an...
[ "def", "anopheles", "(", "self", ")", ":", "list_of_anopheles", "=", "[", "]", "desc", "=", "self", ".", "et", ".", "find", "(", "\"description\"", ")", "if", "desc", "is", "not", "None", ":", "for", "anopheles", "in", "desc", ".", "findall", "(", "\...
:rtype: Anopheles
[ ":", "rtype", ":", "Anopheles" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L989-L1000
train
returns a list of all anopheles in the archive
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
VectorPopIntervention.timesteps
def timesteps(self): """ Time-step at which this intervention occurs, starting from 0, the first intervention-period time-step. https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#-deploy-1 rtype: list """ timesteps = [] timed = self.et.find("timed")...
python
def timesteps(self): """ Time-step at which this intervention occurs, starting from 0, the first intervention-period time-step. https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#-deploy-1 rtype: list """ timesteps = [] timed = self.et.find("timed")...
[ "def", "timesteps", "(", "self", ")", ":", "timesteps", "=", "[", "]", "timed", "=", "self", ".", "et", ".", "find", "(", "\"timed\"", ")", "if", "timed", "is", "not", "None", ":", "for", "deploy", "in", "timed", ".", "findall", "(", "\"deploy\"", ...
Time-step at which this intervention occurs, starting from 0, the first intervention-period time-step. https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#-deploy-1 rtype: list
[ "Time", "-", "step", "at", "which", "this", "intervention", "occurs", "starting", "from", "0", "the", "first", "intervention", "-", "period", "time", "-", "step", ".", "https", ":", "//", "github", ".", "com", "/", "SwissTPH", "/", "openmalaria", "/", "w...
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L1023-L1036
train
Return a list of time - steps at which this intervention occurs starting from 0.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
VectorPop.add
def add(self, intervention, name=None): """ Add an intervention to vectorPop section. intervention is either ElementTree or xml snippet """ if self.et is None: return assert isinstance(intervention, six.string_types) et = ElementTree.fromstring(interv...
python
def add(self, intervention, name=None): """ Add an intervention to vectorPop section. intervention is either ElementTree or xml snippet """ if self.et is None: return assert isinstance(intervention, six.string_types) et = ElementTree.fromstring(interv...
[ "def", "add", "(", "self", ",", "intervention", ",", "name", "=", "None", ")", ":", "if", "self", ".", "et", "is", "None", ":", "return", "assert", "isinstance", "(", "intervention", ",", "six", ".", "string_types", ")", "et", "=", "ElementTree", ".", ...
Add an intervention to vectorPop section. intervention is either ElementTree or xml snippet
[ "Add", "an", "intervention", "to", "vectorPop", "section", ".", "intervention", "is", "either", "ElementTree", "or", "xml", "snippet" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L1046-L1065
train
Add an intervention to vectorPop section.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/interventions.py
VectorPop.interventions
def interventions(self): """ Dictionary of interventions in /scenario/interventions/vectorPop section """ interventions = {} if self.et is None: return interventions for intervention in self.et.findall("intervention"): interventions[intervention.attrib['name']] = ...
python
def interventions(self): """ Dictionary of interventions in /scenario/interventions/vectorPop section """ interventions = {} if self.et is None: return interventions for intervention in self.et.findall("intervention"): interventions[intervention.attrib['name']] = ...
[ "def", "interventions", "(", "self", ")", ":", "interventions", "=", "{", "}", "if", "self", ".", "et", "is", "None", ":", "return", "interventions", "for", "intervention", "in", "self", ".", "et", ".", "findall", "(", "\"intervention\"", ")", ":", "inte...
Dictionary of interventions in /scenario/interventions/vectorPop section
[ "Dictionary", "of", "interventions", "in", "/", "scenario", "/", "interventions", "/", "vectorPop", "section" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L1068-L1075
train
Dictionary of interventions in vectorPop section
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleHistory.position
def position(self, pos=None): """ Get current and/or set history cursor position :param pos: if value is not None, then current position is set to pos and new value is returned :return: int or None (if position have never been changed) """ if pos is not None: if pos >= len(self.__history): raise Inde...
python
def position(self, pos=None): """ Get current and/or set history cursor position :param pos: if value is not None, then current position is set to pos and new value is returned :return: int or None (if position have never been changed) """ if pos is not None: if pos >= len(self.__history): raise Inde...
[ "def", "position", "(", "self", ",", "pos", "=", "None", ")", ":", "if", "pos", "is", "not", "None", ":", "if", "pos", ">=", "len", "(", "self", ".", "__history", ")", ":", "raise", "IndexError", "(", "'History position is out of bound'", ")", "self", ...
Get current and/or set history cursor position :param pos: if value is not None, then current position is set to pos and new value is returned :return: int or None (if position have never been changed)
[ "Get", "current", "and", "/", "or", "set", "history", "cursor", "position" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L55-L66
train
Get current and set history cursor position
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleHistory.add
def add(self, value): """ Add new record to history. Record will be added to the end :param value: new record :return: int record position in history """ index = len(self.__history) self.__history.append(value) return index
python
def add(self, value): """ Add new record to history. Record will be added to the end :param value: new record :return: int record position in history """ index = len(self.__history) self.__history.append(value) return index
[ "def", "add", "(", "self", ",", "value", ")", ":", "index", "=", "len", "(", "self", ".", "__history", ")", "self", ".", "__history", ".", "append", "(", "value", ")", "return", "index" ]
Add new record to history. Record will be added to the end :param value: new record :return: int record position in history
[ "Add", "new", "record", "to", "history", ".", "Record", "will", "be", "added", "to", "the", "end" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L69-L77
train
Add new record to history.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleProto.start_session
def start_session(self): """ Start new session and prepare environment for new row editing process :return: None """ self.__current_row = '' self.__history_mode = False self.__editable_history = deepcopy(self.__history) self.__prompt_show = True self.refresh_window()
python
def start_session(self): """ Start new session and prepare environment for new row editing process :return: None """ self.__current_row = '' self.__history_mode = False self.__editable_history = deepcopy(self.__history) self.__prompt_show = True self.refresh_window()
[ "def", "start_session", "(", "self", ")", ":", "self", ".", "__current_row", "=", "''", "self", ".", "__history_mode", "=", "False", "self", ".", "__editable_history", "=", "deepcopy", "(", "self", ".", "__history", ")", "self", ".", "__prompt_show", "=", ...
Start new session and prepare environment for new row editing process :return: None
[ "Start", "new", "session", "and", "prepare", "environment", "for", "new", "row", "editing", "process" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L139-L148
train
Start new session and prepare environment for new row editing
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleProto.fin_session
def fin_session(self): """ Finalize current session :return: None """ self.__prompt_show = False self.__history.add(self.row()) self.exec(self.row())
python
def fin_session(self): """ Finalize current session :return: None """ self.__prompt_show = False self.__history.add(self.row()) self.exec(self.row())
[ "def", "fin_session", "(", "self", ")", ":", "self", ".", "__prompt_show", "=", "False", "self", ".", "__history", ".", "add", "(", "self", ".", "row", "(", ")", ")", "self", ".", "exec", "(", "self", ".", "row", "(", ")", ")" ]
Finalize current session :return: None
[ "Finalize", "current", "session" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L150-L157
train
Finalize current session
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleProto.update_row
def update_row(self, value): """ Change row :param value: new row :return: None """ if not self.__history_mode: self.__current_row = value else: self.history().update(value, self.history().position())
python
def update_row(self, value): """ Change row :param value: new row :return: None """ if not self.__history_mode: self.__current_row = value else: self.history().update(value, self.history().position())
[ "def", "update_row", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "__history_mode", ":", "self", ".", "__current_row", "=", "value", "else", ":", "self", ".", "history", "(", ")", ".", "update", "(", "value", ",", "self", ".", "hist...
Change row :param value: new row :return: None
[ "Change", "row" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L160-L169
train
Change row with new value
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleProto.row
def row(self): """ Get row :return: str """ if not self.__history_mode: return self.__current_row else: return self.history().entry(self.history().position())
python
def row(self): """ Get row :return: str """ if not self.__history_mode: return self.__current_row else: return self.history().entry(self.history().position())
[ "def", "row", "(", "self", ")", ":", "if", "not", "self", ".", "__history_mode", ":", "return", "self", ".", "__current_row", "else", ":", "return", "self", ".", "history", "(", ")", ".", "entry", "(", "self", ".", "history", "(", ")", ".", "position...
Get row :return: str
[ "Get", "row" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L171-L179
train
Get row in history
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleWindowProto.list_data
def list_data( self, previous_data=False, prompt=False, console_row=False, console_row_to_cursor=False, console_row_from_cursor=False ): """ Return list of strings. Where each string is fitted to windows width. Parameters are the same as they are in :meth:`.WConsoleWindow.data` method :return: list of str ...
python
def list_data( self, previous_data=False, prompt=False, console_row=False, console_row_to_cursor=False, console_row_from_cursor=False ): """ Return list of strings. Where each string is fitted to windows width. Parameters are the same as they are in :meth:`.WConsoleWindow.data` method :return: list of str ...
[ "def", "list_data", "(", "self", ",", "previous_data", "=", "False", ",", "prompt", "=", "False", ",", "console_row", "=", "False", ",", "console_row_to_cursor", "=", "False", ",", "console_row_from_cursor", "=", "False", ")", ":", "return", "self", ".", "sp...
Return list of strings. Where each string is fitted to windows width. Parameters are the same as they are in :meth:`.WConsoleWindow.data` method :return: list of str
[ "Return", "list", "of", "strings", ".", "Where", "each", "string", "is", "fitted", "to", "windows", "width", ".", "Parameters", "are", "the", "same", "as", "they", "are", "in", ":", "meth", ":", ".", "WConsoleWindow", ".", "data", "method" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L336-L347
train
Return list of strings. Where each string is fitted to windows width.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleWindowProto.write_data
def write_data(self, data, start_position=0): """ Write data from the specified line :param data: string to write, each one on new line :param start_position: starting line :return: """ if len(data) > self.height(): raise ValueError('Data too long (too many strings)') for i in range(len(data)): se...
python
def write_data(self, data, start_position=0): """ Write data from the specified line :param data: string to write, each one on new line :param start_position: starting line :return: """ if len(data) > self.height(): raise ValueError('Data too long (too many strings)') for i in range(len(data)): se...
[ "def", "write_data", "(", "self", ",", "data", ",", "start_position", "=", "0", ")", ":", "if", "len", "(", "data", ")", ">", "self", ".", "height", "(", ")", ":", "raise", "ValueError", "(", "'Data too long (too many strings)'", ")", "for", "i", "in", ...
Write data from the specified line :param data: string to write, each one on new line :param start_position: starting line :return:
[ "Write", "data", "from", "the", "specified", "line" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L359-L370
train
Write data to the specified line in the screen.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleWindowProto.split
def split(self, data): """ Split data into list of string, each (self.width() - 1) length or less. If nul-length string specified then empty list is returned :param data: data to split :return: list of str """ line = deepcopy(data) line_width = (self.width() - 1) lines = [] while len(line): new_...
python
def split(self, data): """ Split data into list of string, each (self.width() - 1) length or less. If nul-length string specified then empty list is returned :param data: data to split :return: list of str """ line = deepcopy(data) line_width = (self.width() - 1) lines = [] while len(line): new_...
[ "def", "split", "(", "self", ",", "data", ")", ":", "line", "=", "deepcopy", "(", "data", ")", "line_width", "=", "(", "self", ".", "width", "(", ")", "-", "1", ")", "lines", "=", "[", "]", "while", "len", "(", "line", ")", ":", "new_line", "="...
Split data into list of string, each (self.width() - 1) length or less. If nul-length string specified then empty list is returned :param data: data to split :return: list of str
[ "Split", "data", "into", "list", "of", "string", "each", "(", "self", ".", "width", "()", "-", "1", ")", "length", "or", "less", ".", "If", "nul", "-", "length", "string", "specified", "then", "empty", "list", "is", "returned" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L394-L418
train
Split data into list of string each length or less.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleWindowProto.write_feedback
def write_feedback(self, feedback, cr=True): """ Store feedback. Keep specified feedback as previous output :param feedback: data to store :param cr: whether to write carriage return to the end or not :return: None """ self.__previous_data += feedback if cr is True: self.__previous_data += '\n'
python
def write_feedback(self, feedback, cr=True): """ Store feedback. Keep specified feedback as previous output :param feedback: data to store :param cr: whether to write carriage return to the end or not :return: None """ self.__previous_data += feedback if cr is True: self.__previous_data += '\n'
[ "def", "write_feedback", "(", "self", ",", "feedback", ",", "cr", "=", "True", ")", ":", "self", ".", "__previous_data", "+=", "feedback", "if", "cr", "is", "True", ":", "self", ".", "__previous_data", "+=", "'\\n'" ]
Store feedback. Keep specified feedback as previous output :param feedback: data to store :param cr: whether to write carriage return to the end or not :return: None
[ "Store", "feedback", ".", "Keep", "specified", "feedback", "as", "previous", "output" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L421-L430
train
Store specified feedback.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleWindowBase.refresh
def refresh(self, prompt_show=True): """ Refresh current window. Clear current window and redraw it with one of drawers :param prompt_show: flag, that specifies, whether to show prompt and current row at the windows end, or not :return: None """ self.clear() for drawer in self.__drawers: if drawer.su...
python
def refresh(self, prompt_show=True): """ Refresh current window. Clear current window and redraw it with one of drawers :param prompt_show: flag, that specifies, whether to show prompt and current row at the windows end, or not :return: None """ self.clear() for drawer in self.__drawers: if drawer.su...
[ "def", "refresh", "(", "self", ",", "prompt_show", "=", "True", ")", ":", "self", ".", "clear", "(", ")", "for", "drawer", "in", "self", ".", "__drawers", ":", "if", "drawer", ".", "suitable", "(", "self", ",", "prompt_show", "=", "prompt_show", ")", ...
Refresh current window. Clear current window and redraw it with one of drawers :param prompt_show: flag, that specifies, whether to show prompt and current row at the windows end, or not :return: None
[ "Refresh", "current", "window", ".", "Clear", "current", "window", "and", "redraw", "it", "with", "one", "of", "drawers" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L484-L498
train
Refresh current window. Clear current window and redraw all drawers that are available.
a1ezzz/wasp-general
wasp_general/cli/cli.py
WConsoleBase.write
def write(self, result, cr=True): """ Shortcut for self.window().write_feedback(result) call :param result: same as feedback in :meth:`WConsoleWindowProto.write_feedback` :param cr: same as cr in :meth:`WConsoleWindowProto.write_feedback` :return: None """ self.window().write_feedback(result, cr=cr)
python
def write(self, result, cr=True): """ Shortcut for self.window().write_feedback(result) call :param result: same as feedback in :meth:`WConsoleWindowProto.write_feedback` :param cr: same as cr in :meth:`WConsoleWindowProto.write_feedback` :return: None """ self.window().write_feedback(result, cr=cr)
[ "def", "write", "(", "self", ",", "result", ",", "cr", "=", "True", ")", ":", "self", ".", "window", "(", ")", ".", "write_feedback", "(", "result", ",", "cr", "=", "cr", ")" ]
Shortcut for self.window().write_feedback(result) call :param result: same as feedback in :meth:`WConsoleWindowProto.write_feedback` :param cr: same as cr in :meth:`WConsoleWindowProto.write_feedback` :return: None
[ "Shortcut", "for", "self", ".", "window", "()", ".", "write_feedback", "(", "result", ")", "call" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cli/cli.py#L531-L538
train
Shortcut for self. window. write_feedback
contains-io/typet
typet/path.py
is_dir
def is_dir(path): """Determine if a Path or string is a directory on the file system.""" try: return path.expanduser().absolute().is_dir() except AttributeError: return os.path.isdir(os.path.abspath(os.path.expanduser(str(path))))
python
def is_dir(path): """Determine if a Path or string is a directory on the file system.""" try: return path.expanduser().absolute().is_dir() except AttributeError: return os.path.isdir(os.path.abspath(os.path.expanduser(str(path))))
[ "def", "is_dir", "(", "path", ")", ":", "try", ":", "return", "path", ".", "expanduser", "(", ")", ".", "absolute", "(", ")", ".", "is_dir", "(", ")", "except", "AttributeError", ":", "return", "os", ".", "path", ".", "isdir", "(", "os", ".", "path...
Determine if a Path or string is a directory on the file system.
[ "Determine", "if", "a", "Path", "or", "string", "is", "a", "directory", "on", "the", "file", "system", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L30-L35
train
Determine if a Path or string is a directory on the file system.
contains-io/typet
typet/path.py
is_file
def is_file(path): """Determine if a Path or string is a file on the file system.""" try: return path.expanduser().absolute().is_file() except AttributeError: return os.path.isfile(os.path.abspath(os.path.expanduser(str(path))))
python
def is_file(path): """Determine if a Path or string is a file on the file system.""" try: return path.expanduser().absolute().is_file() except AttributeError: return os.path.isfile(os.path.abspath(os.path.expanduser(str(path))))
[ "def", "is_file", "(", "path", ")", ":", "try", ":", "return", "path", ".", "expanduser", "(", ")", ".", "absolute", "(", ")", ".", "is_file", "(", ")", "except", "AttributeError", ":", "return", "os", ".", "path", ".", "isfile", "(", "os", ".", "p...
Determine if a Path or string is a file on the file system.
[ "Determine", "if", "a", "Path", "or", "string", "is", "a", "file", "on", "the", "file", "system", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L38-L43
train
Determine if a Path or string is a file on the file system.
contains-io/typet
typet/path.py
exists
def exists(path): """Determine if a Path or string is an existing path on the file system.""" try: return path.expanduser().absolute().exists() except AttributeError: return os.path.exists(os.path.abspath(os.path.expanduser(str(path))))
python
def exists(path): """Determine if a Path or string is an existing path on the file system.""" try: return path.expanduser().absolute().exists() except AttributeError: return os.path.exists(os.path.abspath(os.path.expanduser(str(path))))
[ "def", "exists", "(", "path", ")", ":", "try", ":", "return", "path", ".", "expanduser", "(", ")", ".", "absolute", "(", ")", ".", "exists", "(", ")", "except", "AttributeError", ":", "return", "os", ".", "path", ".", "exists", "(", "os", ".", "pat...
Determine if a Path or string is an existing path on the file system.
[ "Determine", "if", "a", "Path", "or", "string", "is", "an", "existing", "path", "on", "the", "file", "system", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/path.py#L46-L51
train
Determine if a Path or string is an existing path on the file system.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
UndoKillLine.commit
def commit(self): """ Delete the rest of the line. """ # Get the text cursor for the current document and unselect everything. tc = self.qteWidget.textCursor() tc.clearSelection() # If this is the first ever call to this undo/redo element then # backup t...
python
def commit(self): """ Delete the rest of the line. """ # Get the text cursor for the current document and unselect everything. tc = self.qteWidget.textCursor() tc.clearSelection() # If this is the first ever call to this undo/redo element then # backup t...
[ "def", "commit", "(", "self", ")", ":", "# Get the text cursor for the current document and unselect everything.", "tc", "=", "self", ".", "qteWidget", ".", "textCursor", "(", ")", "tc", ".", "clearSelection", "(", ")", "# If this is the first ever call to this undo/redo el...
Delete the rest of the line.
[ "Delete", "the", "rest", "of", "the", "line", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L234-L268
train
Commit the changes to the current document.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
UndoKillLine.reverseCommit
def reverseCommit(self): """ Re-insert the previously deleted line. """ # Get the text cursor for the current document. tc = self.qteWidget.textCursor() # Re-insert the deleted text at the correct position. tc.setPosition(self.cursorPos0) tc.insertHtml(s...
python
def reverseCommit(self): """ Re-insert the previously deleted line. """ # Get the text cursor for the current document. tc = self.qteWidget.textCursor() # Re-insert the deleted text at the correct position. tc.setPosition(self.cursorPos0) tc.insertHtml(s...
[ "def", "reverseCommit", "(", "self", ")", ":", "# Get the text cursor for the current document.", "tc", "=", "self", ".", "qteWidget", ".", "textCursor", "(", ")", "# Re-insert the deleted text at the correct position.", "tc", ".", "setPosition", "(", "self", ".", "curs...
Re-insert the previously deleted line.
[ "Re", "-", "insert", "the", "previously", "deleted", "line", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L270-L283
train
Re - insert the previously deleted line.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
UndoYank.commit
def commit(self): """ Delete the rest of the line. """ # Get the text cursor for the current document and unselect # everything. tc = self.qteWidget.textCursor() tc.clearSelection() # If this is the first ever call to this undo/redo element then ...
python
def commit(self): """ Delete the rest of the line. """ # Get the text cursor for the current document and unselect # everything. tc = self.qteWidget.textCursor() tc.clearSelection() # If this is the first ever call to this undo/redo element then ...
[ "def", "commit", "(", "self", ")", ":", "# Get the text cursor for the current document and unselect", "# everything.", "tc", "=", "self", ".", "qteWidget", ".", "textCursor", "(", ")", "tc", ".", "clearSelection", "(", ")", "# If this is the first ever call to this undo/...
Delete the rest of the line.
[ "Delete", "the", "rest", "of", "the", "line", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L332-L363
train
Commits the changes to the current line and deletes the rest of the line.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
UndoYank.reverseCommit
def reverseCommit(self): """ Re-insert the previously removed character(s). """ # Get the text cursor for the current document. tc = self.qteWidget.textCursor() # Mark the previously inserted text and remove it. tc.setPosition(self.cursorPos0, QtGui.QTextCursor.M...
python
def reverseCommit(self): """ Re-insert the previously removed character(s). """ # Get the text cursor for the current document. tc = self.qteWidget.textCursor() # Mark the previously inserted text and remove it. tc.setPosition(self.cursorPos0, QtGui.QTextCursor.M...
[ "def", "reverseCommit", "(", "self", ")", ":", "# Get the text cursor for the current document.", "tc", "=", "self", ".", "qteWidget", ".", "textCursor", "(", ")", "# Mark the previously inserted text and remove it.", "tc", ".", "setPosition", "(", "self", ".", "cursorP...
Re-insert the previously removed character(s).
[ "Re", "-", "insert", "the", "previously", "removed", "character", "(", "s", ")", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L365-L379
train
Re - insert the previously inserted character ( s ).
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
YankPop.enableHook
def enableHook(self, msgObj): """ Enable yank-pop. This method is connected to the 'yank-qtmacs_text_edit' hook (triggered by the yank macro) to ensure that yank-pop only gets activated afterwards. """ self.killListIdx = len(qte_global.kill_list) - 2 self...
python
def enableHook(self, msgObj): """ Enable yank-pop. This method is connected to the 'yank-qtmacs_text_edit' hook (triggered by the yank macro) to ensure that yank-pop only gets activated afterwards. """ self.killListIdx = len(qte_global.kill_list) - 2 self...
[ "def", "enableHook", "(", "self", ",", "msgObj", ")", ":", "self", ".", "killListIdx", "=", "len", "(", "qte_global", ".", "kill_list", ")", "-", "2", "self", ".", "qteMain", ".", "qtesigKeyseqComplete", ".", "connect", "(", "self", ".", "disableHook", "...
Enable yank-pop. This method is connected to the 'yank-qtmacs_text_edit' hook (triggered by the yank macro) to ensure that yank-pop only gets activated afterwards.
[ "Enable", "yank", "-", "pop", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L483-L492
train
Enable hook for yank - pop only.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
BracketMatching.cursorPositionChangedEvent
def cursorPositionChangedEvent(self): """ Update the highlighting. This is an overloaded version of the native Qt slot of ``QTextEdit``. In this class, the purpose of this slot is to check if the character to the right of the cursor needs highlighting, assuming ...
python
def cursorPositionChangedEvent(self): """ Update the highlighting. This is an overloaded version of the native Qt slot of ``QTextEdit``. In this class, the purpose of this slot is to check if the character to the right of the cursor needs highlighting, assuming ...
[ "def", "cursorPositionChangedEvent", "(", "self", ")", ":", "# Determine the sender and cursor position.", "qteWidget", "=", "self", ".", "sender", "(", ")", "tc", "=", "qteWidget", ".", "textCursor", "(", ")", "origin", "=", "tc", ".", "position", "(", ")", "...
Update the highlighting. This is an overloaded version of the native Qt slot of ``QTextEdit``. In this class, the purpose of this slot is to check if the character to the right of the cursor needs highlighting, assuming there is a second character to pair with it. |Arg...
[ "Update", "the", "highlighting", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L899-L991
train
Update the highlighting.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
BracketMatching.qteRemoveHighlighting
def qteRemoveHighlighting(self, widgetObj): """ Remove the highlighting from previously highlighted characters. The method access instance variables to determine which characters are currently highlighted and have to be converted to non-highlighted ones. |Args| ...
python
def qteRemoveHighlighting(self, widgetObj): """ Remove the highlighting from previously highlighted characters. The method access instance variables to determine which characters are currently highlighted and have to be converted to non-highlighted ones. |Args| ...
[ "def", "qteRemoveHighlighting", "(", "self", ",", "widgetObj", ")", ":", "# Retrieve the widget specific macro data.", "data", "=", "self", ".", "qteMacroData", "(", "widgetObj", ")", "if", "not", "data", ":", "return", "# If the data structure is empty then no previously...
Remove the highlighting from previously highlighted characters. The method access instance variables to determine which characters are currently highlighted and have to be converted to non-highlighted ones. |Args| * ``widgetObj`` (**QWidget**): the ``QTextEdit`` to use. ...
[ "Remove", "the", "highlighting", "from", "previously", "highlighted", "characters", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L993-L1034
train
Remove the highlighting from previously highlighted characters.
olitheolix/qtmacs
qtmacs/extensions/qtmacstextedit_macros.py
BracketMatching.highlightCharacters
def highlightCharacters(self, widgetObj, setPos, colorCode, fontWeight, charFormat=None): """ Change the character format of one or more characters. If ``charFormat`` is **None** then only the color and font weight of the characters are changed to ``colorCode...
python
def highlightCharacters(self, widgetObj, setPos, colorCode, fontWeight, charFormat=None): """ Change the character format of one or more characters. If ``charFormat`` is **None** then only the color and font weight of the characters are changed to ``colorCode...
[ "def", "highlightCharacters", "(", "self", ",", "widgetObj", ",", "setPos", ",", "colorCode", ",", "fontWeight", ",", "charFormat", "=", "None", ")", ":", "# Get the text cursor and character format.", "textCursor", "=", "widgetObj", ".", "textCursor", "(", ")", "...
Change the character format of one or more characters. If ``charFormat`` is **None** then only the color and font weight of the characters are changed to ``colorCode`` and ``fontWeight``, respectively. |Args| * ``widgetObj`` (**QWidget**): the ``QTextEdit`` holding t...
[ "Change", "the", "character", "format", "of", "one", "or", "more", "characters", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacstextedit_macros.py#L1036-L1122
train
Highlights the characters in the specified set of characters.
vecnet/vecnet.openmalaria
vecnet/openmalaria/experiment.py
ExperimentSpecification.scenarios
def scenarios(self, generate_seed=False): """ Generator function. Spits out scenarios for this experiment """ seed = prime_numbers(1000) sweeps_all = self.experiment["sweeps"].keys() if "combinations" in self.experiment: if isinstance(self.experiment["combinat...
python
def scenarios(self, generate_seed=False): """ Generator function. Spits out scenarios for this experiment """ seed = prime_numbers(1000) sweeps_all = self.experiment["sweeps"].keys() if "combinations" in self.experiment: if isinstance(self.experiment["combinat...
[ "def", "scenarios", "(", "self", ",", "generate_seed", "=", "False", ")", ":", "seed", "=", "prime_numbers", "(", "1000", ")", "sweeps_all", "=", "self", ".", "experiment", "[", "\"sweeps\"", "]", ".", "keys", "(", ")", "if", "\"combinations\"", "in", "s...
Generator function. Spits out scenarios for this experiment
[ "Generator", "function", ".", "Spits", "out", "scenarios", "for", "this", "experiment" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/experiment.py#L99-L177
train
Generates all scenarios for this experiment.
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLVMInfoCommand.lvm_info
def lvm_info(self, name=None): """ Call a program :param name: if specified - program will return information for that lvm-entity only. otherwise - all available entries are returned :return: tuple of str (fields) """ cmd = [] if self.sudo() is False else ['sudo'] cmd.extend([self.command(), '-c']) if...
python
def lvm_info(self, name=None): """ Call a program :param name: if specified - program will return information for that lvm-entity only. otherwise - all available entries are returned :return: tuple of str (fields) """ cmd = [] if self.sudo() is False else ['sudo'] cmd.extend([self.command(), '-c']) if...
[ "def", "lvm_info", "(", "self", ",", "name", "=", "None", ")", ":", "cmd", "=", "[", "]", "if", "self", ".", "sudo", "(", ")", "is", "False", "else", "[", "'sudo'", "]", "cmd", ".", "extend", "(", "[", "self", ".", "command", "(", ")", ",", "...
Call a program :param name: if specified - program will return information for that lvm-entity only. otherwise - all available entries are returned :return: tuple of str (fields)
[ "Call", "a", "program" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L95-L119
train
Call a program if name is not None
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLogicalVolume.uuid
def uuid(self): """ Return UUID of logical volume :return: str """ uuid_file = '/sys/block/%s/dm/uuid' % os.path.basename(os.path.realpath(self.volume_path())) lv_uuid = open(uuid_file).read().strip() if lv_uuid.startswith('LVM-') is True: return lv_uuid[4:] return lv_uuid
python
def uuid(self): """ Return UUID of logical volume :return: str """ uuid_file = '/sys/block/%s/dm/uuid' % os.path.basename(os.path.realpath(self.volume_path())) lv_uuid = open(uuid_file).read().strip() if lv_uuid.startswith('LVM-') is True: return lv_uuid[4:] return lv_uuid
[ "def", "uuid", "(", "self", ")", ":", "uuid_file", "=", "'/sys/block/%s/dm/uuid'", "%", "os", ".", "path", ".", "basename", "(", "os", ".", "path", ".", "realpath", "(", "self", ".", "volume_path", "(", ")", ")", ")", "lv_uuid", "=", "open", "(", "uu...
Return UUID of logical volume :return: str
[ "Return", "UUID", "of", "logical", "volume" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L457-L466
train
Return UUID of logical volume
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLogicalVolume.create_snapshot
def create_snapshot(self, snapshot_size, snapshot_suffix): """ Create snapshot for this logical volume. :param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \ logical volume space (of this logical volume) :param snapshot_suffix: suffix for logical volume name (base...
python
def create_snapshot(self, snapshot_size, snapshot_suffix): """ Create snapshot for this logical volume. :param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \ logical volume space (of this logical volume) :param snapshot_suffix: suffix for logical volume name (base...
[ "def", "create_snapshot", "(", "self", ",", "snapshot_size", ",", "snapshot_suffix", ")", ":", "size_extent", "=", "math", ".", "ceil", "(", "self", ".", "extents_count", "(", ")", "*", "snapshot_size", ")", "size_kb", "=", "self", ".", "volume_group", "(", ...
Create snapshot for this logical volume. :param snapshot_size: size of newly created snapshot volume. This size is a fraction of the source \ logical volume space (of this logical volume) :param snapshot_suffix: suffix for logical volume name (base part is the same as the original volume \ name) :return: WL...
[ "Create", "snapshot", "for", "this", "logical", "volume", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L470-L490
train
Create a snapshot of this logical volume.
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLogicalVolume.remove_volume
def remove_volume(self): """ Remove this volume :return: None """ lvremove_cmd = ['sudo'] if self.lvm_command().sudo() is True else [] lvremove_cmd.extend(['lvremove', '-f', self.volume_path()]) subprocess.check_output(lvremove_cmd, timeout=self.__class__.__lvm_snapshot_remove_cmd_timeout__)
python
def remove_volume(self): """ Remove this volume :return: None """ lvremove_cmd = ['sudo'] if self.lvm_command().sudo() is True else [] lvremove_cmd.extend(['lvremove', '-f', self.volume_path()]) subprocess.check_output(lvremove_cmd, timeout=self.__class__.__lvm_snapshot_remove_cmd_timeout__)
[ "def", "remove_volume", "(", "self", ")", ":", "lvremove_cmd", "=", "[", "'sudo'", "]", "if", "self", ".", "lvm_command", "(", ")", ".", "sudo", "(", ")", "is", "True", "else", "[", "]", "lvremove_cmd", ".", "extend", "(", "[", "'lvremove'", ",", "'-...
Remove this volume :return: None
[ "Remove", "this", "volume" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L492-L499
train
Remove this volume
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLogicalVolume.snapshot_allocation
def snapshot_allocation(self): """ Return allocated size (fraction of total snapshot volume space). If this is not a snapshot volume, than RuntimeError exception is raised. :return: float """ check_cmd = ['lvs', self.volume_path(), '-o', 'snap_percent', '--noheadings'] output = subprocess.check_output(chec...
python
def snapshot_allocation(self): """ Return allocated size (fraction of total snapshot volume space). If this is not a snapshot volume, than RuntimeError exception is raised. :return: float """ check_cmd = ['lvs', self.volume_path(), '-o', 'snap_percent', '--noheadings'] output = subprocess.check_output(chec...
[ "def", "snapshot_allocation", "(", "self", ")", ":", "check_cmd", "=", "[", "'lvs'", ",", "self", ".", "volume_path", "(", ")", ",", "'-o'", ",", "'snap_percent'", ",", "'--noheadings'", "]", "output", "=", "subprocess", ".", "check_output", "(", "check_cmd"...
Return allocated size (fraction of total snapshot volume space). If this is not a snapshot volume, than RuntimeError exception is raised. :return: float
[ "Return", "allocated", "size", "(", "fraction", "of", "total", "snapshot", "volume", "space", ")", ".", "If", "this", "is", "not", "a", "snapshot", "volume", "than", "RuntimeError", "exception", "is", "raised", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L501-L512
train
Return allocated size of the logical volume.
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
WLogicalVolume.logical_volume
def logical_volume(cls, file_path, sudo=False): """ Return logical volume that stores the given path :param file_path: target path to search :param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__` :return: WLogicalVolume or None (if file path is outside current mount points) """ mp = WMountPoint.mo...
python
def logical_volume(cls, file_path, sudo=False): """ Return logical volume that stores the given path :param file_path: target path to search :param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__` :return: WLogicalVolume or None (if file path is outside current mount points) """ mp = WMountPoint.mo...
[ "def", "logical_volume", "(", "cls", ",", "file_path", ",", "sudo", "=", "False", ")", ":", "mp", "=", "WMountPoint", ".", "mount_point", "(", "file_path", ")", "if", "mp", "is", "not", "None", ":", "name_file", "=", "'/sys/block/%s/dm/name'", "%", "mp", ...
Return logical volume that stores the given path :param file_path: target path to search :param sudo: same as 'sudo' in :meth:`.WLogicalVolume.__init__` :return: WLogicalVolume or None (if file path is outside current mount points)
[ "Return", "logical", "volume", "that", "stores", "the", "given", "path" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L524-L536
train
Return a WLogicalVolume that stores the given path
a1ezzz/wasp-general
wasp_general/io.py
WAESWriter.write
def write(self, b): """ Encrypt and write data :param b: data to encrypt and write :return: None """ self.__buffer += bytes(b) bytes_written = 0 while len(self.__buffer) >= self.__cipher_block_size: io.BufferedWriter.write(self, self.__cipher.encrypt_block(self.__buffer[:self.__cipher_block_size])) ...
python
def write(self, b): """ Encrypt and write data :param b: data to encrypt and write :return: None """ self.__buffer += bytes(b) bytes_written = 0 while len(self.__buffer) >= self.__cipher_block_size: io.BufferedWriter.write(self, self.__cipher.encrypt_block(self.__buffer[:self.__cipher_block_size])) ...
[ "def", "write", "(", "self", ",", "b", ")", ":", "self", ".", "__buffer", "+=", "bytes", "(", "b", ")", "bytes_written", "=", "0", "while", "len", "(", "self", ".", "__buffer", ")", ">=", "self", ".", "__cipher_block_size", ":", "io", ".", "BufferedW...
Encrypt and write data :param b: data to encrypt and write :return: None
[ "Encrypt", "and", "write", "data" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/io.py#L205-L218
train
Encrypt and write data self. Write data to the output buffer.
a1ezzz/wasp-general
wasp_general/uri.py
WURI.component
def component(self, component, value=None): """ Set and/or get component value. :param component: component name to return :param value: if value is not None, this value will be set as a component value :return: str """ if isinstance(component, str) is True: component = WURI.Component(component) if va...
python
def component(self, component, value=None): """ Set and/or get component value. :param component: component name to return :param value: if value is not None, this value will be set as a component value :return: str """ if isinstance(component, str) is True: component = WURI.Component(component) if va...
[ "def", "component", "(", "self", ",", "component", ",", "value", "=", "None", ")", ":", "if", "isinstance", "(", "component", ",", "str", ")", "is", "True", ":", "component", "=", "WURI", ".", "Component", "(", "component", ")", "if", "value", "is", ...
Set and/or get component value. :param component: component name to return :param value: if value is not None, this value will be set as a component value :return: str
[ "Set", "and", "/", "or", "get", "component", "value", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L122-L134
train
Set and or get component value.
a1ezzz/wasp-general
wasp_general/uri.py
WURI.reset_component
def reset_component(self, component): """ Unset component in this URI :param component: component name (or component type) to reset :return: None """ if isinstance(component, str) is True: component = WURI.Component(component) self.__components[component] = None
python
def reset_component(self, component): """ Unset component in this URI :param component: component name (or component type) to reset :return: None """ if isinstance(component, str) is True: component = WURI.Component(component) self.__components[component] = None
[ "def", "reset_component", "(", "self", ",", "component", ")", ":", "if", "isinstance", "(", "component", ",", "str", ")", "is", "True", ":", "component", "=", "WURI", ".", "Component", "(", "component", ")", "self", ".", "__components", "[", "component", ...
Unset component in this URI :param component: component name (or component type) to reset :return: None
[ "Unset", "component", "in", "this", "URI" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L137-L146
train
Reset the component in this URI
a1ezzz/wasp-general
wasp_general/uri.py
WURI.parse
def parse(cls, uri): """ Parse URI-string and return WURI object :param uri: string to parse :return: WURI """ uri_components = urlsplit(uri) adapter_fn = lambda x: x if x is not None and (isinstance(x, str) is False or len(x)) > 0 else None return cls( scheme=adapter_fn(uri_components.scheme), us...
python
def parse(cls, uri): """ Parse URI-string and return WURI object :param uri: string to parse :return: WURI """ uri_components = urlsplit(uri) adapter_fn = lambda x: x if x is not None and (isinstance(x, str) is False or len(x)) > 0 else None return cls( scheme=adapter_fn(uri_components.scheme), us...
[ "def", "parse", "(", "cls", ",", "uri", ")", ":", "uri_components", "=", "urlsplit", "(", "uri", ")", "adapter_fn", "=", "lambda", "x", ":", "x", "if", "x", "is", "not", "None", "and", "(", "isinstance", "(", "x", ",", "str", ")", "is", "False", ...
Parse URI-string and return WURI object :param uri: string to parse :return: WURI
[ "Parse", "URI", "-", "string", "and", "return", "WURI", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L150-L168
train
Parse URI - string and return WURI object
a1ezzz/wasp-general
wasp_general/uri.py
WURIQuery.add_parameter
def add_parameter(self, name, value=None): """ Add new parameter value to this query. New value will be appended to previously added values. :param name: parameter name :param value: value to add (None to set null-value) :return: None """ if name not in self.__query: self.__query[name] = [value] else:...
python
def add_parameter(self, name, value=None): """ Add new parameter value to this query. New value will be appended to previously added values. :param name: parameter name :param value: value to add (None to set null-value) :return: None """ if name not in self.__query: self.__query[name] = [value] else:...
[ "def", "add_parameter", "(", "self", ",", "name", ",", "value", "=", "None", ")", ":", "if", "name", "not", "in", "self", ".", "__query", ":", "self", ".", "__query", "[", "name", "]", "=", "[", "value", "]", "else", ":", "self", ".", "__query", ...
Add new parameter value to this query. New value will be appended to previously added values. :param name: parameter name :param value: value to add (None to set null-value) :return: None
[ "Add", "new", "parameter", "value", "to", "this", "query", ".", "New", "value", "will", "be", "appended", "to", "previously", "added", "values", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L202-L212
train
Add new parameter value to this query.
a1ezzz/wasp-general
wasp_general/uri.py
WURIQuery.remove_parameter
def remove_parameter(self, name): """ Remove the specified parameter from this query :param name: name of a parameter to remove :return: None """ if name in self.__query: self.__query.pop(name)
python
def remove_parameter(self, name): """ Remove the specified parameter from this query :param name: name of a parameter to remove :return: None """ if name in self.__query: self.__query.pop(name)
[ "def", "remove_parameter", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "__query", ":", "self", ".", "__query", ".", "pop", "(", "name", ")" ]
Remove the specified parameter from this query :param name: name of a parameter to remove :return: None
[ "Remove", "the", "specified", "parameter", "from", "this", "query" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L215-L222
train
Removes the specified parameter from this query.
a1ezzz/wasp-general
wasp_general/uri.py
WURIQuery.parse
def parse(cls, query_str): """ Parse string that represent query component from URI :param query_str: string without '?'-sign :return: WURIQuery """ parsed_query = parse_qs(query_str, keep_blank_values=True, strict_parsing=True) result = cls() for parameter_name in parsed_query.keys(): for parameter_v...
python
def parse(cls, query_str): """ Parse string that represent query component from URI :param query_str: string without '?'-sign :return: WURIQuery """ parsed_query = parse_qs(query_str, keep_blank_values=True, strict_parsing=True) result = cls() for parameter_name in parsed_query.keys(): for parameter_v...
[ "def", "parse", "(", "cls", ",", "query_str", ")", ":", "parsed_query", "=", "parse_qs", "(", "query_str", ",", "keep_blank_values", "=", "True", ",", "strict_parsing", "=", "True", ")", "result", "=", "cls", "(", ")", "for", "parameter_name", "in", "parse...
Parse string that represent query component from URI :param query_str: string without '?'-sign :return: WURIQuery
[ "Parse", "string", "that", "represent", "query", "component", "from", "URI" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L261-L275
train
Parse string that represent query component from URI
a1ezzz/wasp-general
wasp_general/uri.py
WStrictURIQuery.add_specification
def add_specification(self, specification): """ Add a new query parameter specification. If this object already has a specification for the specified parameter - exception is raised. No checks for the specified or any parameter are made regarding specification appending :param specification: new specification ...
python
def add_specification(self, specification): """ Add a new query parameter specification. If this object already has a specification for the specified parameter - exception is raised. No checks for the specified or any parameter are made regarding specification appending :param specification: new specification ...
[ "def", "add_specification", "(", "self", ",", "specification", ")", ":", "name", "=", "specification", ".", "name", "(", ")", "if", "name", "in", "self", ".", "__specs", ":", "raise", "ValueError", "(", "'WStrictURIQuery object already has specification for paramete...
Add a new query parameter specification. If this object already has a specification for the specified parameter - exception is raised. No checks for the specified or any parameter are made regarding specification appending :param specification: new specification that will be added :return: None
[ "Add", "a", "new", "query", "parameter", "specification", ".", "If", "this", "object", "already", "has", "a", "specification", "for", "the", "specified", "parameter", "-", "exception", "is", "raised", ".", "No", "checks", "for", "the", "specified", "or", "an...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L380-L391
train
Add a new query parameter specification.
a1ezzz/wasp-general
wasp_general/uri.py
WStrictURIQuery.remove_specification
def remove_specification(self, name): """ Remove a specification that matches a query parameter. No checks for the specified or any parameter are made regarding specification removing :param name: parameter name to remove :return: None """ if name in self.__specs: self.__specs.pop(name)
python
def remove_specification(self, name): """ Remove a specification that matches a query parameter. No checks for the specified or any parameter are made regarding specification removing :param name: parameter name to remove :return: None """ if name in self.__specs: self.__specs.pop(name)
[ "def", "remove_specification", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "__specs", ":", "self", ".", "__specs", ".", "pop", "(", "name", ")" ]
Remove a specification that matches a query parameter. No checks for the specified or any parameter are made regarding specification removing :param name: parameter name to remove :return: None
[ "Remove", "a", "specification", "that", "matches", "a", "query", "parameter", ".", "No", "checks", "for", "the", "specified", "or", "any", "parameter", "are", "made", "regarding", "specification", "removing" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L394-L402
train
Removes a specification that matches a query parameter.
a1ezzz/wasp-general
wasp_general/uri.py
WStrictURIQuery.replace_parameter
def replace_parameter(self, name, value=None): """ Replace a query parameter values with a new value. If a new value does not match current specifications, then exception is raised :param name: parameter name to replace :param value: new parameter value. None is for empty (null) value :return: None """ s...
python
def replace_parameter(self, name, value=None): """ Replace a query parameter values with a new value. If a new value does not match current specifications, then exception is raised :param name: parameter name to replace :param value: new parameter value. None is for empty (null) value :return: None """ s...
[ "def", "replace_parameter", "(", "self", ",", "name", ",", "value", "=", "None", ")", ":", "spec", "=", "self", ".", "__specs", "[", "name", "]", "if", "name", "in", "self", ".", "__specs", "else", "None", "if", "self", ".", "extra_parameters", "(", ...
Replace a query parameter values with a new value. If a new value does not match current specifications, then exception is raised :param name: parameter name to replace :param value: new parameter value. None is for empty (null) value :return: None
[ "Replace", "a", "query", "parameter", "values", "with", "a", "new", "value", ".", "If", "a", "new", "value", "does", "not", "match", "current", "specifications", "then", "exception", "is", "raised" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L405-L425
train
Replaces a query parameter value with a new value.
a1ezzz/wasp-general
wasp_general/uri.py
WStrictURIQuery.remove_parameter
def remove_parameter(self, name): """ Remove parameter from this query. If a parameter is mandatory, then exception is raised :param name: parameter name to remove :return: None """ spec = self.__specs[name] if name in self.__specs else None if spec is not None and spec.optional() is False: raise ValueE...
python
def remove_parameter(self, name): """ Remove parameter from this query. If a parameter is mandatory, then exception is raised :param name: parameter name to remove :return: None """ spec = self.__specs[name] if name in self.__specs else None if spec is not None and spec.optional() is False: raise ValueE...
[ "def", "remove_parameter", "(", "self", ",", "name", ")", ":", "spec", "=", "self", ".", "__specs", "[", "name", "]", "if", "name", "in", "self", ".", "__specs", "else", "None", "if", "spec", "is", "not", "None", "and", "spec", ".", "optional", "(", ...
Remove parameter from this query. If a parameter is mandatory, then exception is raised :param name: parameter name to remove :return: None
[ "Remove", "parameter", "from", "this", "query", ".", "If", "a", "parameter", "is", "mandatory", "then", "exception", "is", "raised" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L454-L464
train
Removes a parameter from this query.
a1ezzz/wasp-general
wasp_general/uri.py
WStrictURIQuery.strict_parse
def strict_parse(cls, query_str, *specs, extra_parameters=True): """ Parse query and return :class:`.WStrictURIQuery` object :param query_str: query component of URI to parse :param specs: list of parameters specifications :param extra_parameters: whether parameters that was not specified in "specs" are allowe...
python
def strict_parse(cls, query_str, *specs, extra_parameters=True): """ Parse query and return :class:`.WStrictURIQuery` object :param query_str: query component of URI to parse :param specs: list of parameters specifications :param extra_parameters: whether parameters that was not specified in "specs" are allowe...
[ "def", "strict_parse", "(", "cls", ",", "query_str", ",", "*", "specs", ",", "extra_parameters", "=", "True", ")", ":", "plain_result", "=", "cls", ".", "parse", "(", "query_str", ")", "return", "WStrictURIQuery", "(", "plain_result", ",", "*", "specs", ",...
Parse query and return :class:`.WStrictURIQuery` object :param query_str: query component of URI to parse :param specs: list of parameters specifications :param extra_parameters: whether parameters that was not specified in "specs" are allowed :return: WStrictURIQuery
[ "Parse", "query", "and", "return", ":", "class", ":", ".", "WStrictURIQuery", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L478-L487
train
Parse a query string and return a WStrictURIQuery object.
a1ezzz/wasp-general
wasp_general/uri.py
WURIComponentVerifier.validate
def validate(self, uri): """ Check an URI for compatibility with this specification. Return True if the URI is compatible. :param uri: an URI to check :return: bool """ requirement = self.requirement() uri_component = uri.component(self.component()) if uri_component is None: return requirement != WU...
python
def validate(self, uri): """ Check an URI for compatibility with this specification. Return True if the URI is compatible. :param uri: an URI to check :return: bool """ requirement = self.requirement() uri_component = uri.component(self.component()) if uri_component is None: return requirement != WU...
[ "def", "validate", "(", "self", ",", "uri", ")", ":", "requirement", "=", "self", ".", "requirement", "(", ")", "uri_component", "=", "uri", ".", "component", "(", "self", ".", "component", "(", ")", ")", "if", "uri_component", "is", "None", ":", "retu...
Check an URI for compatibility with this specification. Return True if the URI is compatible. :param uri: an URI to check :return: bool
[ "Check", "an", "URI", "for", "compatibility", "with", "this", "specification", ".", "Return", "True", "if", "the", "URI", "is", "compatible", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L537-L555
train
Check an URI for compatibility with this specification. Return True if the URI is compatible. Return False otherwise.
a1ezzz/wasp-general
wasp_general/uri.py
WURIQueryVerifier.validate
def validate(self, uri): """ Check that an query part of an URI is compatible with this descriptor. Return True if the URI is compatible. :param uri: an URI to check :return: bool """ if WURIComponentVerifier.validate(self, uri) is False: return False try: WStrictURIQuery( WURIQuery.parse(uri....
python
def validate(self, uri): """ Check that an query part of an URI is compatible with this descriptor. Return True if the URI is compatible. :param uri: an URI to check :return: bool """ if WURIComponentVerifier.validate(self, uri) is False: return False try: WStrictURIQuery( WURIQuery.parse(uri....
[ "def", "validate", "(", "self", ",", "uri", ")", ":", "if", "WURIComponentVerifier", ".", "validate", "(", "self", ",", "uri", ")", "is", "False", ":", "return", "False", "try", ":", "WStrictURIQuery", "(", "WURIQuery", ".", "parse", "(", "uri", ".", "...
Check that an query part of an URI is compatible with this descriptor. Return True if the URI is compatible. :param uri: an URI to check :return: bool
[ "Check", "that", "an", "query", "part", "of", "an", "URI", "is", "compatible", "with", "this", "descriptor", ".", "Return", "True", "if", "the", "URI", "is", "compatible", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L576-L594
train
Check that an URI is compatible with this descriptor. Return True if the URI is not compatible.
a1ezzz/wasp-general
wasp_general/uri.py
WSchemeSpecification.is_compatible
def is_compatible(self, uri): """ Check if URI is compatible with this specification. Compatible URI has scheme name that matches specification scheme name, has all of the required components, does not have unsupported components and may have optional components :param uri: URI to check :return: bool """ ...
python
def is_compatible(self, uri): """ Check if URI is compatible with this specification. Compatible URI has scheme name that matches specification scheme name, has all of the required components, does not have unsupported components and may have optional components :param uri: URI to check :return: bool """ ...
[ "def", "is_compatible", "(", "self", ",", "uri", ")", ":", "for", "component", ",", "component_value", "in", "uri", ":", "if", "self", ".", "verifier", "(", "component", ")", ".", "validate", "(", "uri", ")", "is", "False", ":", "return", "False", "ret...
Check if URI is compatible with this specification. Compatible URI has scheme name that matches specification scheme name, has all of the required components, does not have unsupported components and may have optional components :param uri: URI to check :return: bool
[ "Check", "if", "URI", "is", "compatible", "with", "this", "specification", ".", "Compatible", "URI", "has", "scheme", "name", "that", "matches", "specification", "scheme", "name", "has", "all", "of", "the", "required", "components", "does", "not", "have", "uns...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L658-L670
train
Check if URI is compatible with this specification.
a1ezzz/wasp-general
wasp_general/uri.py
WSchemeCollection.handler
def handler(self, scheme_name=None): """ Return handler which scheme name matches the specified one :param scheme_name: scheme name to search for :return: WSchemeHandler class or None (if matching handler was not found) """ if scheme_name is None: return self.__default_handler_cls for handler in self.__...
python
def handler(self, scheme_name=None): """ Return handler which scheme name matches the specified one :param scheme_name: scheme name to search for :return: WSchemeHandler class or None (if matching handler was not found) """ if scheme_name is None: return self.__default_handler_cls for handler in self.__...
[ "def", "handler", "(", "self", ",", "scheme_name", "=", "None", ")", ":", "if", "scheme_name", "is", "None", ":", "return", "self", ".", "__default_handler_cls", "for", "handler", "in", "self", ".", "__handlers_cls", ":", "if", "handler", ".", "scheme_specif...
Return handler which scheme name matches the specified one :param scheme_name: scheme name to search for :return: WSchemeHandler class or None (if matching handler was not found)
[ "Return", "handler", "which", "scheme", "name", "matches", "the", "specified", "one" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L752-L762
train
Return handler which scheme name matches the specified one
a1ezzz/wasp-general
wasp_general/uri.py
WSchemeCollection.open
def open(self, uri, **kwargs): """ Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and WSchemeCollection.SchemeIncompatible may be raised. :param uri: URI to search handler for :param kwargs: additional arguments that may be used by a handler specialization :return: W...
python
def open(self, uri, **kwargs): """ Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and WSchemeCollection.SchemeIncompatible may be raised. :param uri: URI to search handler for :param kwargs: additional arguments that may be used by a handler specialization :return: W...
[ "def", "open", "(", "self", ",", "uri", ",", "*", "*", "kwargs", ")", ":", "handler", "=", "self", ".", "handler", "(", "uri", ".", "scheme", "(", ")", ")", "if", "handler", "is", "None", ":", "raise", "WSchemeCollection", ".", "NoHandlerFound", "(",...
Return handler instance that matches the specified URI. WSchemeCollection.NoHandlerFound and WSchemeCollection.SchemeIncompatible may be raised. :param uri: URI to search handler for :param kwargs: additional arguments that may be used by a handler specialization :return: WSchemeHandler
[ "Return", "handler", "instance", "that", "matches", "the", "specified", "URI", ".", "WSchemeCollection", ".", "NoHandlerFound", "and", "WSchemeCollection", ".", "SchemeIncompatible", "may", "be", "raised", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L765-L783
train
Return handler instance that matches the specified URI.
olitheolix/qtmacs
qtmacs/applets/webbrowser.py
WebBrowser.loadFile
def loadFile(self, fileName): """ Load the URL ``fileName``. """ self.fileName = fileName self.qteWeb.load(QtCore.QUrl(fileName))
python
def loadFile(self, fileName): """ Load the URL ``fileName``. """ self.fileName = fileName self.qteWeb.load(QtCore.QUrl(fileName))
[ "def", "loadFile", "(", "self", ",", "fileName", ")", ":", "self", ".", "fileName", "=", "fileName", "self", ".", "qteWeb", ".", "load", "(", "QtCore", ".", "QUrl", "(", "fileName", ")", ")" ]
Load the URL ``fileName``.
[ "Load", "the", "URL", "fileName", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/webbrowser.py#L85-L90
train
Load the file with the given name.
weijia/djangoautoconf
djangoautoconf/class_based_views/ajax_views.py
AjaxableViewMixin.render_to_response
def render_to_response(self, context, **response_kwargs): """ Returns a response with a template rendered with the given context. """ context["ajax_form_id"] = self.ajax_form_id # context["base_template"] = "towel_bootstrap/modal.html" return self.response_class( ...
python
def render_to_response(self, context, **response_kwargs): """ Returns a response with a template rendered with the given context. """ context["ajax_form_id"] = self.ajax_form_id # context["base_template"] = "towel_bootstrap/modal.html" return self.response_class( ...
[ "def", "render_to_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "context", "[", "\"ajax_form_id\"", "]", "=", "self", ".", "ajax_form_id", "# context[\"base_template\"] = \"towel_bootstrap/modal.html\"", "return", "self", ".", "re...
Returns a response with a template rendered with the given context.
[ "Returns", "a", "response", "with", "a", "template", "rendered", "with", "the", "given", "context", "." ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/ajax_views.py#L47-L58
train
Returns a response with a template rendered with the given context.
consbio/restle
restle/fields.py
TextField.to_python
def to_python(self, value, resource): """Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode""" if value is None: return self._transform(value) if isinstance(value, six.text_type): return self._transform(value) i...
python
def to_python(self, value, resource): """Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode""" if value is None: return self._transform(value) if isinstance(value, six.text_type): return self._transform(value) i...
[ "def", "to_python", "(", "self", ",", "value", ",", "resource", ")", ":", "if", "value", "is", "None", ":", "return", "self", ".", "_transform", "(", "value", ")", "if", "isinstance", "(", "value", ",", "six", ".", "text_type", ")", ":", "return", "s...
Converts to unicode if `self.encoding != None`, otherwise returns input without attempting to decode
[ "Converts", "to", "unicode", "if", "self", ".", "encoding", "!", "=", "None", "otherwise", "returns", "input", "without", "attempting", "to", "decode" ]
60d100da034c612d4910f4f79eaa57a76eb3dcc6
https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L72-L87
train
Converts to unicode if self. encoding!= None otherwise returns input without attempting to decode
consbio/restle
restle/fields.py
ObjectField.to_python
def to_python(self, value, resource): """Dictionary to Python object""" if isinstance(value, dict): d = { self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v for k, v in six.iteritems(value) } retu...
python
def to_python(self, value, resource): """Dictionary to Python object""" if isinstance(value, dict): d = { self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v for k, v in six.iteritems(value) } retu...
[ "def", "to_python", "(", "self", ",", "value", ",", "resource", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "d", "=", "{", "self", ".", "aliases", ".", "get", "(", "k", ",", "k", ")", ":", "self", ".", "to_python", "(", "...
Dictionary to Python object
[ "Dictionary", "to", "Python", "object" ]
60d100da034c612d4910f4f79eaa57a76eb3dcc6
https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L145-L157
train
Dictionary to Python object
consbio/restle
restle/fields.py
ObjectField.to_value
def to_value(self, obj, resource, visited=set()): """Python object to dictionary""" if id(obj) in visited: raise ValueError('Circular reference detected when attempting to serialize object') if isinstance(obj, (list, tuple, set)): return [self.to_value(x, resource) if h...
python
def to_value(self, obj, resource, visited=set()): """Python object to dictionary""" if id(obj) in visited: raise ValueError('Circular reference detected when attempting to serialize object') if isinstance(obj, (list, tuple, set)): return [self.to_value(x, resource) if h...
[ "def", "to_value", "(", "self", ",", "obj", ",", "resource", ",", "visited", "=", "set", "(", ")", ")", ":", "if", "id", "(", "obj", ")", "in", "visited", ":", "raise", "ValueError", "(", "'Circular reference detected when attempting to serialize object'", ")"...
Python object to dictionary
[ "Python", "object", "to", "dictionary" ]
60d100da034c612d4910f4f79eaa57a76eb3dcc6
https://github.com/consbio/restle/blob/60d100da034c612d4910f4f79eaa57a76eb3dcc6/restle/fields.py#L159-L179
train
Convert a Python object to a dictionary.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger.hello_message
def hello_message(self, invert_hello=False): """ Return message header. :param invert_hello: whether to return the original header (in case of False value) or reversed \ one (in case of True value). :return: bytes """ if invert_hello is False: return self.__gouverneur_message hello_message = [] for...
python
def hello_message(self, invert_hello=False): """ Return message header. :param invert_hello: whether to return the original header (in case of False value) or reversed \ one (in case of True value). :return: bytes """ if invert_hello is False: return self.__gouverneur_message hello_message = [] for...
[ "def", "hello_message", "(", "self", ",", "invert_hello", "=", "False", ")", ":", "if", "invert_hello", "is", "False", ":", "return", "self", ".", "__gouverneur_message", "hello_message", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ...
Return message header. :param invert_hello: whether to return the original header (in case of False value) or reversed \ one (in case of True value). :return: bytes
[ "Return", "message", "header", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L200-L213
train
Return message header.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger._message
def _message(self, beacon_config, invert_hello=False): """ Generate request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :param invert_hello: return message with reverse header when this argument is set ...
python
def _message(self, beacon_config, invert_hello=False): """ Generate request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :param invert_hello: return message with reverse header when this argument is set ...
[ "def", "_message", "(", "self", ",", "beacon_config", ",", "invert_hello", "=", "False", ")", ":", "message", "=", "self", ".", "hello_message", "(", "invert_hello", "=", "invert_hello", ")", "+", "self", ".", "_message_address_generate", "(", "beacon_config", ...
Generate request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :param invert_hello: return message with reverse header when this argument is set to True. :return: bytes
[ "Generate", "request", "/", "response", "message", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L216-L226
train
Generate request or response message.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger._message_address_generate
def _message_address_generate(self, beacon_config): """ Generate address for request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :return: bytes """ address = None if beacon_config['wasp-general:...
python
def _message_address_generate(self, beacon_config): """ Generate address for request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :return: bytes """ address = None if beacon_config['wasp-general:...
[ "def", "_message_address_generate", "(", "self", ",", "beacon_config", ")", ":", "address", "=", "None", "if", "beacon_config", "[", "'wasp-general::network::beacon'", "]", "[", "'public_address'", "]", "!=", "''", ":", "address", "=", "str", "(", "WIPV4SocketInfo...
Generate address for request/response message. :param beacon_config: server or client configuration. Client configuration is used for request and \ server configuration for response :return: bytes
[ "Generate", "address", "for", "request", "/", "response", "message", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L229-L251
train
Generate address for request or response message.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger._message_address_parse
def _message_address_parse(self, message, invert_hello=False): """ Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns :param message: message to parse :param invert_hello: defines whether message header is the original one or reversed. :return: WIPV4SocketInfo ...
python
def _message_address_parse(self, message, invert_hello=False): """ Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns :param message: message to parse :param invert_hello: defines whether message header is the original one or reversed. :return: WIPV4SocketInfo ...
[ "def", "_message_address_parse", "(", "self", ",", "message", ",", "invert_hello", "=", "False", ")", ":", "message_header", "=", "self", ".", "hello_message", "(", "invert_hello", "=", "invert_hello", ")", "if", "message", "[", ":", "len", "(", "message_heade...
Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns :param message: message to parse :param invert_hello: defines whether message header is the original one or reversed. :return: WIPV4SocketInfo
[ "Read", "address", "from", "beacon", "message", ".", "If", "no", "address", "is", "specified", "then", "nullable", "WIPV4SocketInfo", "returns" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L254-L280
train
Read address from beacon message.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger.has_response
def has_response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request header with internal one. """ try: self._message_address_parse(request, invert_hello=self.__invert_hello) return True except ValueError: p...
python
def has_response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request header with internal one. """ try: self._message_address_parse(request, invert_hello=self.__invert_hello) return True except ValueError: p...
[ "def", "has_response", "(", "self", ",", "beacon_config", ",", "request", ",", "client_address", ")", ":", "try", ":", "self", ".", "_message_address_parse", "(", "request", ",", "invert_hello", "=", "self", ".", "__invert_hello", ")", "return", "True", "excep...
:meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request header with internal one.
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "has_response", "method", "implementation", ".", "This", "method", "compares", "request", "header", "with", "internal", "one", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L291-L300
train
This method is used to check if beacon_config. beacon_config.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger.response
def response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger` """ return self._message(beacon_config, invert_hello=self.__invert_hello)
python
def response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger` """ return self._message(beacon_config, invert_hello=self.__invert_hello)
[ "def", "response", "(", "self", ",", "beacon_config", ",", "request", ",", "client_address", ")", ":", "return", "self", ".", "_message", "(", "beacon_config", ",", "invert_hello", "=", "self", ".", "__invert_hello", ")" ]
:meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger`
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "request", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L303-L308
train
method implementation. beacon_config beacon_config. request beacon_config. client_address beacon_config. client_address
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger.response_address
def response_address(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger` """ si = self._message_address_parse(request, invert_hello=self.__invert_hello) address = si.address() port = si.port() return WIPV...
python
def response_address(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger` """ si = self._message_address_parse(request, invert_hello=self.__invert_hello) address = si.address() port = si.port() return WIPV...
[ "def", "response_address", "(", "self", ",", "beacon_config", ",", "request", ",", "client_address", ")", ":", "si", "=", "self", ".", "_message_address_parse", "(", "request", ",", "invert_hello", "=", "self", ".", "__invert_hello", ")", "address", "=", "si",...
:meth:`.WBeaconMessengerBase.request` method implementation. see :class:`.WBeaconGouverneurMessenger`
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "request", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L312-L323
train
method implementation. response_address
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WBeaconGouverneurMessenger.valid_response
def valid_response(self, beacon_config, response, server_address): """ :meth:`.WBeaconMessengerBase.valid_response` method implementation. Response when it has correct header. Response header must be reversed if this messenger was constructed with 'invert_hello' flag. """ try: self._message_address_parse(res...
python
def valid_response(self, beacon_config, response, server_address): """ :meth:`.WBeaconMessengerBase.valid_response` method implementation. Response when it has correct header. Response header must be reversed if this messenger was constructed with 'invert_hello' flag. """ try: self._message_address_parse(res...
[ "def", "valid_response", "(", "self", ",", "beacon_config", ",", "response", ",", "server_address", ")", ":", "try", ":", "self", ".", "_message_address_parse", "(", "response", ",", "invert_hello", "=", "self", ".", "__invert_hello", ")", "return", "True", "e...
:meth:`.WBeaconMessengerBase.valid_response` method implementation. Response when it has correct header. Response header must be reversed if this messenger was constructed with 'invert_hello' flag.
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "valid_response", "method", "implementation", ".", "Response", "when", "it", "has", "correct", "header", ".", "Response", "header", "must", "be", "reversed", "if", "this", "messenger", "was", "constructed", "wi...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L326-L335
train
This method is used to check if response is valid.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WHostgroupBeaconMessenger._message
def _message(self, beacon_config, invert_hello=False): """ Overridden :meth:`.WBeaconGouverneurMessenger._message` method. Appends encoded host group names to requests and responses. :param beacon_config: beacon configuration :return: bytes """ m = WBeaconGouverneurMessenger._message(self, beacon_config, i...
python
def _message(self, beacon_config, invert_hello=False): """ Overridden :meth:`.WBeaconGouverneurMessenger._message` method. Appends encoded host group names to requests and responses. :param beacon_config: beacon configuration :return: bytes """ m = WBeaconGouverneurMessenger._message(self, beacon_config, i...
[ "def", "_message", "(", "self", ",", "beacon_config", ",", "invert_hello", "=", "False", ")", ":", "m", "=", "WBeaconGouverneurMessenger", ".", "_message", "(", "self", ",", "beacon_config", ",", "invert_hello", "=", "invert_hello", ")", "hostgroups", "=", "se...
Overridden :meth:`.WBeaconGouverneurMessenger._message` method. Appends encoded host group names to requests and responses. :param beacon_config: beacon configuration :return: bytes
[ "Overridden", ":", "meth", ":", ".", "WBeaconGouverneurMessenger", ".", "_message", "method", ".", "Appends", "encoded", "host", "group", "names", "to", "requests", "and", "responses", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L400-L411
train
Overridden method. Appends encoded host group names to requests and responses.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WHostgroupBeaconMessenger._message_hostgroup_parse
def _message_hostgroup_parse(self, message): """ Parse given message and return list of group names and socket information. Socket information is parsed in :meth:`.WBeaconGouverneurMessenger._message_address_parse` method :param message: bytes :return: tuple of list of group names and WIPV4SocketInfo """ s...
python
def _message_hostgroup_parse(self, message): """ Parse given message and return list of group names and socket information. Socket information is parsed in :meth:`.WBeaconGouverneurMessenger._message_address_parse` method :param message: bytes :return: tuple of list of group names and WIPV4SocketInfo """ s...
[ "def", "_message_hostgroup_parse", "(", "self", ",", "message", ")", ":", "splitter_count", "=", "message", ".", "count", "(", "WHostgroupBeaconMessenger", ".", "__message_groups_splitter__", ")", "if", "splitter_count", "==", "0", ":", "return", "[", "]", ",", ...
Parse given message and return list of group names and socket information. Socket information is parsed in :meth:`.WBeaconGouverneurMessenger._message_address_parse` method :param message: bytes :return: tuple of list of group names and WIPV4SocketInfo
[ "Parse", "given", "message", "and", "return", "list", "of", "group", "names", "and", "socket", "information", ".", "Socket", "information", "is", "parsed", "in", ":", "meth", ":", ".", "WBeaconGouverneurMessenger", ".", "_message_address_parse", "method" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L420-L439
train
Parse given message and return list of group names and socket information.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WHostgroupBeaconMessenger.has_response
def has_response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request headers as :meth:`.WBeaconGouverneurMessenger.has_response` do and compares specified group names with internal names. """ try: groups, address ...
python
def has_response(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request headers as :meth:`.WBeaconGouverneurMessenger.has_response` do and compares specified group names with internal names. """ try: groups, address ...
[ "def", "has_response", "(", "self", ",", "beacon_config", ",", "request", ",", "client_address", ")", ":", "try", ":", "groups", ",", "address", "=", "self", ".", "_message_hostgroup_parse", "(", "request", ")", "if", "len", "(", "self", ".", "__hostgroups",...
:meth:`.WBeaconMessengerBase.has_response` method implementation. This method compares request headers as :meth:`.WBeaconGouverneurMessenger.has_response` do and compares specified group names with internal names.
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "has_response", "method", "implementation", ".", "This", "method", "compares", "request", "headers", "as", ":", "meth", ":", ".", "WBeaconGouverneurMessenger", ".", "has_response", "do", "and", "compares", "speci...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L442-L459
train
This method compares request with beacon_config.
a1ezzz/wasp-general
wasp_general/network/beacon/messenger.py
WHostgroupBeaconMessenger.response_address
def response_address(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.response_address` method implementation. It just removes host group names part and return :meth:`.WBeaconMessengerBase.response_address` result """ si = self._message_hostgroup_parse(request)[1] address = si.a...
python
def response_address(self, beacon_config, request, client_address): """ :meth:`.WBeaconMessengerBase.response_address` method implementation. It just removes host group names part and return :meth:`.WBeaconMessengerBase.response_address` result """ si = self._message_hostgroup_parse(request)[1] address = si.a...
[ "def", "response_address", "(", "self", ",", "beacon_config", ",", "request", ",", "client_address", ")", ":", "si", "=", "self", ".", "_message_hostgroup_parse", "(", "request", ")", "[", "1", "]", "address", "=", "si", ".", "address", "(", ")", "port", ...
:meth:`.WBeaconMessengerBase.response_address` method implementation. It just removes host group names part and return :meth:`.WBeaconMessengerBase.response_address` result
[ ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "response_address", "method", "implementation", ".", "It", "just", "removes", "host", "group", "names", "part", "and", "return", ":", "meth", ":", ".", "WBeaconMessengerBase", ".", "response_address", "result" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/messenger.py#L463-L473
train
This method is used to get the response address from the beacon config. It just removes host group names part and returns WIPV4SocketInfo object.
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WSimplePadding.pad
def pad(self, data, block_size): """ :meth:`.WBlockPadding.pad` method implementation """ padding_symbol = self.padding_symbol() blocks_count = (len(data) // block_size) if (len(data) % block_size) != 0: blocks_count += 1 total_length = blocks_count * block_size return self._fill(data, total_length, ...
python
def pad(self, data, block_size): """ :meth:`.WBlockPadding.pad` method implementation """ padding_symbol = self.padding_symbol() blocks_count = (len(data) // block_size) if (len(data) % block_size) != 0: blocks_count += 1 total_length = blocks_count * block_size return self._fill(data, total_length, ...
[ "def", "pad", "(", "self", ",", "data", ",", "block_size", ")", ":", "padding_symbol", "=", "self", ".", "padding_symbol", "(", ")", "blocks_count", "=", "(", "len", "(", "data", ")", "//", "block_size", ")", "if", "(", "len", "(", "data", ")", "%", ...
:meth:`.WBlockPadding.pad` method implementation
[ ":", "meth", ":", ".", "WBlockPadding", ".", "pad", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L92-L102
train
method implementation for padding
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WShiftPadding._fill
def _fill(self, data, total_length, padding_symbol): """ Overridden :meth:`.WSimplePadding._fill` method. This methods adds padding symbol at the beginning and at the end of the specified data. :param data: data to append to :param total_length: target length :param padding_symbol: symbol to pad :return: b...
python
def _fill(self, data, total_length, padding_symbol): """ Overridden :meth:`.WSimplePadding._fill` method. This methods adds padding symbol at the beginning and at the end of the specified data. :param data: data to append to :param total_length: target length :param padding_symbol: symbol to pad :return: b...
[ "def", "_fill", "(", "self", ",", "data", ",", "total_length", ",", "padding_symbol", ")", ":", "delta", "=", "total_length", "-", "len", "(", "data", ")", "return", "(", "(", "padding_symbol", "*", "random_int", "(", "delta", ")", ")", "+", "data", ")...
Overridden :meth:`.WSimplePadding._fill` method. This methods adds padding symbol at the beginning and at the end of the specified data. :param data: data to append to :param total_length: target length :param padding_symbol: symbol to pad :return: bytes
[ "Overridden", ":", "meth", ":", ".", "WSimplePadding", ".", "_fill", "method", ".", "This", "methods", "adds", "padding", "symbol", "at", "the", "beginning", "and", "at", "the", "end", "of", "the", "specified", "data", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L142-L153
train
Overridden method.
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WShiftPadding.reverse_pad
def reverse_pad(self, data, block_size): """ :meth:`.WBlockPadding.reverse_pad` method implementation """ padding_symbol = self.padding_symbol() return data.lstrip(padding_symbol).rstrip(padding_symbol)
python
def reverse_pad(self, data, block_size): """ :meth:`.WBlockPadding.reverse_pad` method implementation """ padding_symbol = self.padding_symbol() return data.lstrip(padding_symbol).rstrip(padding_symbol)
[ "def", "reverse_pad", "(", "self", ",", "data", ",", "block_size", ")", ":", "padding_symbol", "=", "self", ".", "padding_symbol", "(", ")", "return", "data", ".", "lstrip", "(", "padding_symbol", ")", ".", "rstrip", "(", "padding_symbol", ")" ]
:meth:`.WBlockPadding.reverse_pad` method implementation
[ ":", "meth", ":", ".", "WBlockPadding", ".", "reverse_pad", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L157-L161
train
method implementation for reverse_pad
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WPKCS7Padding.pad
def pad(self, data, block_size): """ :meth:`.WBlockPadding.pad` method implementation """ pad_byte = block_size - (len(data) % block_size) return data + bytes([pad_byte] * pad_byte)
python
def pad(self, data, block_size): """ :meth:`.WBlockPadding.pad` method implementation """ pad_byte = block_size - (len(data) % block_size) return data + bytes([pad_byte] * pad_byte)
[ "def", "pad", "(", "self", ",", "data", ",", "block_size", ")", ":", "pad_byte", "=", "block_size", "-", "(", "len", "(", "data", ")", "%", "block_size", ")", "return", "data", "+", "bytes", "(", "[", "pad_byte", "]", "*", "pad_byte", ")" ]
:meth:`.WBlockPadding.pad` method implementation
[ ":", "meth", ":", ".", "WBlockPadding", ".", "pad", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L172-L176
train
method implementation for padding
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WPKCS7Padding.reverse_pad
def reverse_pad(self, data, block_size): """ :meth:`.WBlockPadding.reverse_pad` method implementation """ pad_byte = data[-1] if pad_byte > block_size: raise ValueError('Invalid padding') padding = bytes([pad_byte] * pad_byte) if data[-pad_byte:] != padding: raise ValueError('Invalid padding') ret...
python
def reverse_pad(self, data, block_size): """ :meth:`.WBlockPadding.reverse_pad` method implementation """ pad_byte = data[-1] if pad_byte > block_size: raise ValueError('Invalid padding') padding = bytes([pad_byte] * pad_byte) if data[-pad_byte:] != padding: raise ValueError('Invalid padding') ret...
[ "def", "reverse_pad", "(", "self", ",", "data", ",", "block_size", ")", ":", "pad_byte", "=", "data", "[", "-", "1", "]", "if", "pad_byte", ">", "block_size", ":", "raise", "ValueError", "(", "'Invalid padding'", ")", "padding", "=", "bytes", "(", "[", ...
:meth:`.WBlockPadding.reverse_pad` method implementation
[ ":", "meth", ":", ".", "WBlockPadding", ".", "reverse_pad", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L180-L191
train
Method implementation for reverse_pad
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WAESMode.parse_cipher_name
def parse_cipher_name(cls, name): """ Parse cipher name (name like 'aes_256_cbc' or 'AES-128-CTR'). Also this method validates If the cipher is supported by this class. If no - exception is raised :param name: name to parse :return: tuple where the first element is a key size in bytes (int) and the second ele...
python
def parse_cipher_name(cls, name): """ Parse cipher name (name like 'aes_256_cbc' or 'AES-128-CTR'). Also this method validates If the cipher is supported by this class. If no - exception is raised :param name: name to parse :return: tuple where the first element is a key size in bytes (int) and the second ele...
[ "def", "parse_cipher_name", "(", "cls", ",", "name", ")", ":", "r", "=", "cls", ".", "__mode_re__", ".", "match", "(", "name", ".", "upper", "(", ")", ")", "if", "r", "is", "None", ":", "raise", "ValueError", "(", "'Unable to find suitable cipher for: \"%s...
Parse cipher name (name like 'aes_256_cbc' or 'AES-128-CTR'). Also this method validates If the cipher is supported by this class. If no - exception is raised :param name: name to parse :return: tuple where the first element is a key size in bytes (int) and the second element - block cipher mode of operation ...
[ "Parse", "cipher", "name", "(", "name", "like", "aes_256_cbc", "or", "AES", "-", "128", "-", "CTR", ")", ".", "Also", "this", "method", "validates", "If", "the", "cipher", "is", "supported", "by", "this", "class", ".", "If", "no", "-", "exception", "is...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L432-L450
train
Parse a name like AES_256_CBC or AES - 128 - CBC or AES - CBC.
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WAES.cipher
def cipher(self): """ Generate AES-cipher :return: Crypto.Cipher.AES.AESCipher """ #cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs()) cipher = Cipher(*self.mode().aes_args(), **self.mode().aes_kwargs()) return WAES.WAESCipher(cipher)
python
def cipher(self): """ Generate AES-cipher :return: Crypto.Cipher.AES.AESCipher """ #cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs()) cipher = Cipher(*self.mode().aes_args(), **self.mode().aes_kwargs()) return WAES.WAESCipher(cipher)
[ "def", "cipher", "(", "self", ")", ":", "#cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs())", "cipher", "=", "Cipher", "(", "*", "self", ".", "mode", "(", ")", ".", "aes_args", "(", ")", ",", "*", "*", "self", ".", "mode", "(", ")", "."...
Generate AES-cipher :return: Crypto.Cipher.AES.AESCipher
[ "Generate", "AES", "-", "cipher" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L491-L498
train
Generate AES - cipher
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WAES.encrypt
def encrypt(self, data): """ Encrypt the given data with cipher that is got from AES.cipher call. :param data: data to encrypt :return: bytes """ padding = self.mode().padding() if padding is not None: data = padding.pad(data, WAESMode.__data_padding_length__) return self.cipher().encrypt_block(data)
python
def encrypt(self, data): """ Encrypt the given data with cipher that is got from AES.cipher call. :param data: data to encrypt :return: bytes """ padding = self.mode().padding() if padding is not None: data = padding.pad(data, WAESMode.__data_padding_length__) return self.cipher().encrypt_block(data)
[ "def", "encrypt", "(", "self", ",", "data", ")", ":", "padding", "=", "self", ".", "mode", "(", ")", ".", "padding", "(", ")", "if", "padding", "is", "not", "None", ":", "data", "=", "padding", ".", "pad", "(", "data", ",", "WAESMode", ".", "__da...
Encrypt the given data with cipher that is got from AES.cipher call. :param data: data to encrypt :return: bytes
[ "Encrypt", "the", "given", "data", "with", "cipher", "that", "is", "got", "from", "AES", ".", "cipher", "call", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L501-L511
train
Encrypt the given data with cipher that is got from AES. cipher call.
a1ezzz/wasp-general
wasp_general/crypto/aes.py
WAES.decrypt
def decrypt(self, data, decode=False): """ Decrypt the given data with cipher that is got from AES.cipher call. :param data: data to decrypt :param decode: whether to decode bytes to str or not :return: bytes or str (depends on decode flag) """ #result = self.cipher().decrypt(data) result = self.cipher(...
python
def decrypt(self, data, decode=False): """ Decrypt the given data with cipher that is got from AES.cipher call. :param data: data to decrypt :param decode: whether to decode bytes to str or not :return: bytes or str (depends on decode flag) """ #result = self.cipher().decrypt(data) result = self.cipher(...
[ "def", "decrypt", "(", "self", ",", "data", ",", "decode", "=", "False", ")", ":", "#result = self.cipher().decrypt(data)", "result", "=", "self", ".", "cipher", "(", ")", ".", "decrypt_block", "(", "data", ")", "padding", "=", "self", ".", "mode", "(", ...
Decrypt the given data with cipher that is got from AES.cipher call. :param data: data to decrypt :param decode: whether to decode bytes to str or not :return: bytes or str (depends on decode flag)
[ "Decrypt", "the", "given", "data", "with", "cipher", "that", "is", "got", "from", "AES", ".", "cipher", "call", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L515-L530
train
Decrypt the given data with cipher that is got from AES. cipher call.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WThreadTracker.start
def start(self): """ :meth:`.WThreadTask.start` implementation. Register (if required) start event by a tracker storage :return: None """ tracker = self.tracker_storage() if tracker is not None and self.track_start() is True: details = self.event_details(WTrackerEvents.start) tracker.register_start(sel...
python
def start(self): """ :meth:`.WThreadTask.start` implementation. Register (if required) start event by a tracker storage :return: None """ tracker = self.tracker_storage() if tracker is not None and self.track_start() is True: details = self.event_details(WTrackerEvents.start) tracker.register_start(sel...
[ "def", "start", "(", "self", ")", ":", "tracker", "=", "self", ".", "tracker_storage", "(", ")", "if", "tracker", "is", "not", "None", "and", "self", ".", "track_start", "(", ")", "is", "True", ":", "details", "=", "self", ".", "event_details", "(", ...
:meth:`.WThreadTask.start` implementation. Register (if required) start event by a tracker storage :return: None
[ ":", "meth", ":", ".", "WThreadTask", ".", "start", "implementation", ".", "Register", "(", "if", "required", ")", "start", "event", "by", "a", "tracker", "storage" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L222-L231
train
meth :. WThreadTask. start implementation. Register start event by a tracker storage WThreadTask instance.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WThreadTracker.thread_stopped
def thread_stopped(self): """ :meth:`.WThreadTask.thread_stopped` implementation. Register (if required) stop and termination event by a tracker storage :return: None """ tracker = self.tracker_storage() if tracker is not None: try: if self.ready_event().is_set() is True: if self.track_stop() i...
python
def thread_stopped(self): """ :meth:`.WThreadTask.thread_stopped` implementation. Register (if required) stop and termination event by a tracker storage :return: None """ tracker = self.tracker_storage() if tracker is not None: try: if self.ready_event().is_set() is True: if self.track_stop() i...
[ "def", "thread_stopped", "(", "self", ")", ":", "tracker", "=", "self", ".", "tracker_storage", "(", ")", "if", "tracker", "is", "not", "None", ":", "try", ":", "if", "self", ".", "ready_event", "(", ")", ".", "is_set", "(", ")", "is", "True", ":", ...
:meth:`.WThreadTask.thread_stopped` implementation. Register (if required) stop and termination event by a tracker storage :return: None
[ ":", "meth", ":", ".", "WThreadTask", ".", "thread_stopped", "implementation", ".", "Register", "(", "if", "required", ")", "stop", "and", "termination", "event", "by", "a", "tracker", "storage" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L233-L251
train
This method is used to register stop and termination events by a tracker storage if is not None
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WThreadTracker.thread_exception
def thread_exception(self, raised_exception): """ :meth:`.WThreadTask.thread_exception` implementation. Register (if required) unhandled exception event by a tracker storage :param raised_exception: unhandled exception :return: None """ tracker = self.tracker_storage() if tracker is not None: try: ...
python
def thread_exception(self, raised_exception): """ :meth:`.WThreadTask.thread_exception` implementation. Register (if required) unhandled exception event by a tracker storage :param raised_exception: unhandled exception :return: None """ tracker = self.tracker_storage() if tracker is not None: try: ...
[ "def", "thread_exception", "(", "self", ",", "raised_exception", ")", ":", "tracker", "=", "self", ".", "tracker_storage", "(", ")", "if", "tracker", "is", "not", "None", ":", "try", ":", "if", "self", ".", "track_exception", "(", ")", "is", "True", ":",...
:meth:`.WThreadTask.thread_exception` implementation. Register (if required) unhandled exception event by a tracker storage :param raised_exception: unhandled exception :return: None
[ ":", "meth", ":", ".", "WThreadTask", ".", "thread_exception", "implementation", ".", "Register", "(", "if", "required", ")", "unhandled", "exception", "event", "by", "a", "tracker", "storage" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L254-L274
train
method for registering unhandled exception by a tracker storage object.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WThreadTracker.thread_tracker_exception
def thread_tracker_exception(self, raised_exception): """ Method is called whenever an exception is raised during registering a event :param raised_exception: raised exception :return: None """ print('Thread tracker execution was stopped by the exception. Exception: %s' % str(raised_exception)) print('Tra...
python
def thread_tracker_exception(self, raised_exception): """ Method is called whenever an exception is raised during registering a event :param raised_exception: raised exception :return: None """ print('Thread tracker execution was stopped by the exception. Exception: %s' % str(raised_exception)) print('Tra...
[ "def", "thread_tracker_exception", "(", "self", ",", "raised_exception", ")", ":", "print", "(", "'Thread tracker execution was stopped by the exception. Exception: %s'", "%", "str", "(", "raised_exception", ")", ")", "print", "(", "'Traceback:'", ")", "print", "(", "tr...
Method is called whenever an exception is raised during registering a event :param raised_exception: raised exception :return: None
[ "Method", "is", "called", "whenever", "an", "exception", "is", "raised", "during", "registering", "a", "event" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L278-L287
train
Method is called when an exception is raised during registering a thread tracker execution.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_start
def register_start(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_start` method implementation """ if self.record_start() is True: record_type = WTrackerEvents.start record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(reco...
python
def register_start(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_start` method implementation """ if self.record_start() is True: record_type = WTrackerEvents.start record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(reco...
[ "def", "register_start", "(", "self", ",", "task", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_start", "(", ")", "is", "True", ":", "record_type", "=", "WTrackerEvents", ".", "start", "record", "=", "WSimpleTrackerStorage", ".", ...
:meth:`.WSimpleTrackerStorage.register_start` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_start", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L406-L412
train
This method is used to register a start event for the given task.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_stop
def register_stop(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_stop` method implementation """ if self.record_stop() is True: record_type = WTrackerEvents.stop record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
python
def register_stop(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_stop` method implementation """ if self.record_stop() is True: record_type = WTrackerEvents.stop record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
[ "def", "register_stop", "(", "self", ",", "task", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_stop", "(", ")", "is", "True", ":", "record_type", "=", "WTrackerEvents", ".", "stop", "record", "=", "WSimpleTrackerStorage", ".", "R...
:meth:`.WSimpleTrackerStorage.register_stop` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_stop", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L415-L421
train
This method is used to register a stop event in the tracker storage.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_termination
def register_termination(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_termination` method implementation """ if self.record_termination() is True: record_type = WTrackerEvents.termination record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) ...
python
def register_termination(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_termination` method implementation """ if self.record_termination() is True: record_type = WTrackerEvents.termination record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) ...
[ "def", "register_termination", "(", "self", ",", "task", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_termination", "(", ")", "is", "True", ":", "record_type", "=", "WTrackerEvents", ".", "termination", "record", "=", "WSimpleTracker...
:meth:`.WSimpleTrackerStorage.register_termination` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_termination", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L424-L430
train
This method is used to register a termination event.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_exception
def register_exception(self, task, raised_exception, exception_details, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_exception` method implementation """ if self.record_exception() is True: record = WSimpleTrackerStorage.ExceptionRecord( task, raised_exception, exception_details, event_d...
python
def register_exception(self, task, raised_exception, exception_details, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_exception` method implementation """ if self.record_exception() is True: record = WSimpleTrackerStorage.ExceptionRecord( task, raised_exception, exception_details, event_d...
[ "def", "register_exception", "(", "self", ",", "task", ",", "raised_exception", ",", "exception_details", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_exception", "(", ")", "is", "True", ":", "record", "=", "WSimpleTrackerStorage", "...
:meth:`.WSimpleTrackerStorage.register_exception` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_exception", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L433-L440
train
This method is used to register an exception with the tracker.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_wait
def register_wait(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_wait` method implementation """ if self.record_wait() is True: record_type = WTrackerEvents.wait record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
python
def register_wait(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_wait` method implementation """ if self.record_wait() is True: record_type = WTrackerEvents.wait record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
[ "def", "register_wait", "(", "self", ",", "task", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_wait", "(", ")", "is", "True", ":", "record_type", "=", "WTrackerEvents", ".", "wait", "record", "=", "WSimpleTrackerStorage", ".", "R...
:meth:`.WSimpleTrackerStorage.register_wait` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_wait", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L443-L449
train
method to register a wait event
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.register_drop
def register_drop(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_drop` method implementation """ if self.record_drop() is True: record_type = WTrackerEvents.drop record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
python
def register_drop(self, task, event_details=None): """ :meth:`.WSimpleTrackerStorage.register_drop` method implementation """ if self.record_drop() is True: record_type = WTrackerEvents.drop record = WSimpleTrackerStorage.Record(record_type, task, event_details=event_details) self.__store_record(record)
[ "def", "register_drop", "(", "self", ",", "task", ",", "event_details", "=", "None", ")", ":", "if", "self", ".", "record_drop", "(", ")", "is", "True", ":", "record_type", "=", "WTrackerEvents", ".", "drop", "record", "=", "WSimpleTrackerStorage", ".", "R...
:meth:`.WSimpleTrackerStorage.register_drop` method implementation
[ ":", "meth", ":", ".", "WSimpleTrackerStorage", ".", "register_drop", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L452-L458
train
meth :. WSimpleTrackerStorage. register_drop method implementation
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.__store_record
def __store_record(self, record): """ Save record in a internal storage :param record: record to save :return: None """ if isinstance(record, WSimpleTrackerStorage.Record) is False: raise TypeError('Invalid record type was') limit = self.record_limit() if limit is not None and len(self.__registry) >=...
python
def __store_record(self, record): """ Save record in a internal storage :param record: record to save :return: None """ if isinstance(record, WSimpleTrackerStorage.Record) is False: raise TypeError('Invalid record type was') limit = self.record_limit() if limit is not None and len(self.__registry) >=...
[ "def", "__store_record", "(", "self", ",", "record", ")", ":", "if", "isinstance", "(", "record", ",", "WSimpleTrackerStorage", ".", "Record", ")", "is", "False", ":", "raise", "TypeError", "(", "'Invalid record type was'", ")", "limit", "=", "self", ".", "r...
Save record in a internal storage :param record: record to save :return: None
[ "Save", "record", "in", "a", "internal", "storage" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L461-L473
train
Save record in a internal storage.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WSimpleTrackerStorage.last_record
def last_record(self, task_uid, *requested_events): """ Search over registered :class:`.WScheduleTask` instances and return the last record that matches search criteria. :param task_uid: uid of :class:`.WScheduleTask` instance :param requested_events: target events types :return: WSimpleTrackerStorage.Recor...
python
def last_record(self, task_uid, *requested_events): """ Search over registered :class:`.WScheduleTask` instances and return the last record that matches search criteria. :param task_uid: uid of :class:`.WScheduleTask` instance :param requested_events: target events types :return: WSimpleTrackerStorage.Recor...
[ "def", "last_record", "(", "self", ",", "task_uid", ",", "*", "requested_events", ")", ":", "for", "record", "in", "self", ":", "if", "isinstance", "(", "record", ".", "thread_task", ",", "WScheduleTask", ")", "is", "False", ":", "continue", "if", "record"...
Search over registered :class:`.WScheduleTask` instances and return the last record that matches search criteria. :param task_uid: uid of :class:`.WScheduleTask` instance :param requested_events: target events types :return: WSimpleTrackerStorage.Record or None
[ "Search", "over", "registered", ":", "class", ":", ".", "WScheduleTask", "instances", "and", "return", "the", "last", "record", "that", "matches", "search", "criteria", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L494-L508
train
Search over registered : class :. WScheduleTask instances and return the last record that matches the requested_events.
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WScheduleRecordTracker.task_postponed
def task_postponed(self): """ Track (if required) postponing event and do the same job as :meth:`.WScheduleRecord.task_postponed` method do :return: None """ tracker = self.task().tracker_storage() if tracker is not None and self.track_wait() is True: details = self.task().event_details(WTrackerEvents.w...
python
def task_postponed(self): """ Track (if required) postponing event and do the same job as :meth:`.WScheduleRecord.task_postponed` method do :return: None """ tracker = self.task().tracker_storage() if tracker is not None and self.track_wait() is True: details = self.task().event_details(WTrackerEvents.w...
[ "def", "task_postponed", "(", "self", ")", ":", "tracker", "=", "self", ".", "task", "(", ")", ".", "tracker_storage", "(", ")", "if", "tracker", "is", "not", "None", "and", "self", ".", "track_wait", "(", ")", "is", "True", ":", "details", "=", "sel...
Track (if required) postponing event and do the same job as :meth:`.WScheduleRecord.task_postponed` method do :return: None
[ "Track", "(", "if", "required", ")", "postponing", "event", "and", "do", "the", "same", "job", "as", ":", "meth", ":", ".", "WScheduleRecord", ".", "task_postponed", "method", "do" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L559-L569
train
Track if required ) postponing event and do the same job as : meth :. WScheduleRecord. task_postponed
a1ezzz/wasp-general
wasp_general/task/thread_tracker.py
WScheduleRecordTracker.task_dropped
def task_dropped(self): """ Track (if required) drop event and do the same job as :meth:`.WScheduleRecord.task_dropped` method do :return: None """ tracker = self.task().tracker_storage() if tracker is not None and self.track_drop() is True: details = self.task().event_details(WTrackerEvents.drop) tr...
python
def task_dropped(self): """ Track (if required) drop event and do the same job as :meth:`.WScheduleRecord.task_dropped` method do :return: None """ tracker = self.task().tracker_storage() if tracker is not None and self.track_drop() is True: details = self.task().event_details(WTrackerEvents.drop) tr...
[ "def", "task_dropped", "(", "self", ")", ":", "tracker", "=", "self", ".", "task", "(", ")", ".", "tracker_storage", "(", ")", "if", "tracker", "is", "not", "None", "and", "self", ".", "track_drop", "(", ")", "is", "True", ":", "details", "=", "self"...
Track (if required) drop event and do the same job as :meth:`.WScheduleRecord.task_dropped` method do :return: None
[ "Track", "(", "if", "required", ")", "drop", "event", "and", "do", "the", "same", "job", "as", ":", "meth", ":", ".", "WScheduleRecord", ".", "task_dropped", "method", "do" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L571-L581
train
Track drop event and do the same job as :meth :. WScheduleRecord. task_dropped
shaypal5/strct
strct/dicts/_dict.py
get_nested_val
def get_nested_val(key_tuple, dict_obj): """Return a value from nested dicts by the order of the given keys tuple. Parameters ---------- key_tuple : tuple The keys to use for extraction, in order. dict_obj : dict The outer-most dict to extract from. Returns ------- valu...
python
def get_nested_val(key_tuple, dict_obj): """Return a value from nested dicts by the order of the given keys tuple. Parameters ---------- key_tuple : tuple The keys to use for extraction, in order. dict_obj : dict The outer-most dict to extract from. Returns ------- valu...
[ "def", "get_nested_val", "(", "key_tuple", ",", "dict_obj", ")", ":", "if", "len", "(", "key_tuple", ")", "==", "1", ":", "return", "dict_obj", "[", "key_tuple", "[", "0", "]", "]", "return", "get_nested_val", "(", "key_tuple", "[", "1", ":", "]", ",",...
Return a value from nested dicts by the order of the given keys tuple. Parameters ---------- key_tuple : tuple The keys to use for extraction, in order. dict_obj : dict The outer-most dict to extract from. Returns ------- value : object The extracted value, if exist...
[ "Return", "a", "value", "from", "nested", "dicts", "by", "the", "order", "of", "the", "given", "keys", "tuple", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L70-L93
train
Return a value from nested dicts by the given keys tuple.