repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
ampl/amplpy
amplpy/ampl.py
AMPL.getValue
def getValue(self, scalarExpression): """ Get a scalar value from the underlying AMPL interpreter, as a double or a string. Args: scalarExpression: An AMPL expression which evaluates to a scalar value. Returns: The value of the expression. ...
python
def getValue(self, scalarExpression): """ Get a scalar value from the underlying AMPL interpreter, as a double or a string. Args: scalarExpression: An AMPL expression which evaluates to a scalar value. Returns: The value of the expression. ...
[ "def", "getValue", "(", "self", ",", "scalarExpression", ")", ":", "return", "lock_and_call", "(", "lambda", ":", "Utils", ".", "castVariant", "(", "self", ".", "_impl", ".", "getValue", "(", "scalarExpression", ")", ")", ",", "self", ".", "_lock", ")" ]
Get a scalar value from the underlying AMPL interpreter, as a double or a string. Args: scalarExpression: An AMPL expression which evaluates to a scalar value. Returns: The value of the expression.
[ "Get", "a", "scalar", "value", "from", "the", "underlying", "AMPL", "interpreter", "as", "a", "double", "or", "a", "string", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L612-L627
ampl/amplpy
amplpy/ampl.py
AMPL.setData
def setData(self, data, setName=None): """ Assign the data in the dataframe to the AMPL entities with the names corresponding to the column names. Args: data: The dataframe containing the data to be assigned. setName: The name of the set to which the indices val...
python
def setData(self, data, setName=None): """ Assign the data in the dataframe to the AMPL entities with the names corresponding to the column names. Args: data: The dataframe containing the data to be assigned. setName: The name of the set to which the indices val...
[ "def", "setData", "(", "self", ",", "data", ",", "setName", "=", "None", ")", ":", "if", "not", "isinstance", "(", "data", ",", "DataFrame", ")", ":", "if", "pd", "is", "not", "None", "and", "isinstance", "(", "data", ",", "pd", ".", "DataFrame", "...
Assign the data in the dataframe to the AMPL entities with the names corresponding to the column names. Args: data: The dataframe containing the data to be assigned. setName: The name of the set to which the indices values of the DataFrame are to be assigned. ...
[ "Assign", "the", "data", "in", "the", "dataframe", "to", "the", "AMPL", "entities", "with", "the", "names", "corresponding", "to", "the", "column", "names", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L629-L655
ampl/amplpy
amplpy/ampl.py
AMPL.readTable
def readTable(self, tableName): """ Read the table corresponding to the specified name, equivalent to the AMPL statement: .. code-block:: ampl read table tableName; Args: tableName: Name of the table to be read. """ lock_and_call( ...
python
def readTable(self, tableName): """ Read the table corresponding to the specified name, equivalent to the AMPL statement: .. code-block:: ampl read table tableName; Args: tableName: Name of the table to be read. """ lock_and_call( ...
[ "def", "readTable", "(", "self", ",", "tableName", ")", ":", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "readTable", "(", "tableName", ")", ",", "self", ".", "_lock", ")" ]
Read the table corresponding to the specified name, equivalent to the AMPL statement: .. code-block:: ampl read table tableName; Args: tableName: Name of the table to be read.
[ "Read", "the", "table", "corresponding", "to", "the", "specified", "name", "equivalent", "to", "the", "AMPL", "statement", ":" ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L657-L672
ampl/amplpy
amplpy/ampl.py
AMPL.writeTable
def writeTable(self, tableName): """ Write the table corresponding to the specified name, equivalent to the AMPL statement .. code-block:: ampl write table tableName; Args: tableName: Name of the table to be written. """ lock_and_call( ...
python
def writeTable(self, tableName): """ Write the table corresponding to the specified name, equivalent to the AMPL statement .. code-block:: ampl write table tableName; Args: tableName: Name of the table to be written. """ lock_and_call( ...
[ "def", "writeTable", "(", "self", ",", "tableName", ")", ":", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "writeTable", "(", "tableName", ")", ",", "self", ".", "_lock", ")" ]
Write the table corresponding to the specified name, equivalent to the AMPL statement .. code-block:: ampl write table tableName; Args: tableName: Name of the table to be written.
[ "Write", "the", "table", "corresponding", "to", "the", "specified", "name", "equivalent", "to", "the", "AMPL", "statement" ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L674-L689
ampl/amplpy
amplpy/ampl.py
AMPL.display
def display(self, *amplExpressions): """ Writes on the current OutputHandler the outcome of the AMPL statement. .. code-block:: ampl display e1, e2, .., en; where e1, ..., en are the strings passed to the procedure. Args: amplExpressions: Expressions t...
python
def display(self, *amplExpressions): """ Writes on the current OutputHandler the outcome of the AMPL statement. .. code-block:: ampl display e1, e2, .., en; where e1, ..., en are the strings passed to the procedure. Args: amplExpressions: Expressions t...
[ "def", "display", "(", "self", ",", "*", "amplExpressions", ")", ":", "exprs", "=", "list", "(", "map", "(", "str", ",", "amplExpressions", ")", ")", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "displayLst", "(", "exprs", ",", "len"...
Writes on the current OutputHandler the outcome of the AMPL statement. .. code-block:: ampl display e1, e2, .., en; where e1, ..., en are the strings passed to the procedure. Args: amplExpressions: Expressions to be evaluated.
[ "Writes", "on", "the", "current", "OutputHandler", "the", "outcome", "of", "the", "AMPL", "statement", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L691-L708
ampl/amplpy
amplpy/ampl.py
AMPL.setOutputHandler
def setOutputHandler(self, outputhandler): """ Sets a new output handler. Args: outputhandler: The function handling the AMPL output derived from interpreting user commands. """ class OutputHandlerInternal(amplpython.OutputHandler): def output...
python
def setOutputHandler(self, outputhandler): """ Sets a new output handler. Args: outputhandler: The function handling the AMPL output derived from interpreting user commands. """ class OutputHandlerInternal(amplpython.OutputHandler): def output...
[ "def", "setOutputHandler", "(", "self", ",", "outputhandler", ")", ":", "class", "OutputHandlerInternal", "(", "amplpython", ".", "OutputHandler", ")", ":", "def", "output", "(", "self", ",", "kind", ",", "msg", ")", ":", "outputhandler", ".", "output", "(",...
Sets a new output handler. Args: outputhandler: The function handling the AMPL output derived from interpreting user commands.
[ "Sets", "a", "new", "output", "handler", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L710-L729
ampl/amplpy
amplpy/ampl.py
AMPL.setErrorHandler
def setErrorHandler(self, errorhandler): """ Sets a new error handler. Args: errorhandler: The object handling AMPL errors and warnings. """ class ErrorHandlerWrapper(ErrorHandler): def __init__(self, errorhandler): self.errorhandler = err...
python
def setErrorHandler(self, errorhandler): """ Sets a new error handler. Args: errorhandler: The object handling AMPL errors and warnings. """ class ErrorHandlerWrapper(ErrorHandler): def __init__(self, errorhandler): self.errorhandler = err...
[ "def", "setErrorHandler", "(", "self", ",", "errorhandler", ")", ":", "class", "ErrorHandlerWrapper", "(", "ErrorHandler", ")", ":", "def", "__init__", "(", "self", ",", "errorhandler", ")", ":", "self", ".", "errorhandler", "=", "errorhandler", "self", ".", ...
Sets a new error handler. Args: errorhandler: The object handling AMPL errors and warnings.
[ "Sets", "a", "new", "error", "handler", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L731-L779
ampl/amplpy
amplpy/ampl.py
AMPL.getVariables
def getVariables(self): """ Get all the variables declared. """ variables = lock_and_call( lambda: self._impl.getVariables(), self._lock ) return EntityMap(variables, Variable)
python
def getVariables(self): """ Get all the variables declared. """ variables = lock_and_call( lambda: self._impl.getVariables(), self._lock ) return EntityMap(variables, Variable)
[ "def", "getVariables", "(", "self", ")", ":", "variables", "=", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "getVariables", "(", ")", ",", "self", ".", "_lock", ")", "return", "EntityMap", "(", "variables", ",", "Variable", ")" ]
Get all the variables declared.
[ "Get", "all", "the", "variables", "declared", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L799-L807
ampl/amplpy
amplpy/ampl.py
AMPL.getConstraints
def getConstraints(self): """ Get all the constraints declared. """ constraints = lock_and_call( lambda: self._impl.getConstraints(), self._lock ) return EntityMap(constraints, Constraint)
python
def getConstraints(self): """ Get all the constraints declared. """ constraints = lock_and_call( lambda: self._impl.getConstraints(), self._lock ) return EntityMap(constraints, Constraint)
[ "def", "getConstraints", "(", "self", ")", ":", "constraints", "=", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "getConstraints", "(", ")", ",", "self", ".", "_lock", ")", "return", "EntityMap", "(", "constraints", ",", "Constraint", ")...
Get all the constraints declared.
[ "Get", "all", "the", "constraints", "declared", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L809-L817
ampl/amplpy
amplpy/ampl.py
AMPL.getObjectives
def getObjectives(self): """ Get all the objectives declared. """ objectives = lock_and_call( lambda: self._impl.getObjectives(), self._lock ) return EntityMap(objectives, Objective)
python
def getObjectives(self): """ Get all the objectives declared. """ objectives = lock_and_call( lambda: self._impl.getObjectives(), self._lock ) return EntityMap(objectives, Objective)
[ "def", "getObjectives", "(", "self", ")", ":", "objectives", "=", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "getObjectives", "(", ")", ",", "self", ".", "_lock", ")", "return", "EntityMap", "(", "objectives", ",", "Objective", ")" ]
Get all the objectives declared.
[ "Get", "all", "the", "objectives", "declared", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L819-L827
ampl/amplpy
amplpy/ampl.py
AMPL.getSets
def getSets(self): """ Get all the sets declared. """ sets = lock_and_call( lambda: self._impl.getSets(), self._lock ) return EntityMap(sets, Set)
python
def getSets(self): """ Get all the sets declared. """ sets = lock_and_call( lambda: self._impl.getSets(), self._lock ) return EntityMap(sets, Set)
[ "def", "getSets", "(", "self", ")", ":", "sets", "=", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "getSets", "(", ")", ",", "self", ".", "_lock", ")", "return", "EntityMap", "(", "sets", ",", "Set", ")" ]
Get all the sets declared.
[ "Get", "all", "the", "sets", "declared", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L829-L837
ampl/amplpy
amplpy/ampl.py
AMPL.getParameters
def getParameters(self): """ Get all the parameters declared. """ parameters = lock_and_call( lambda: self._impl.getParameters(), self._lock ) return EntityMap(parameters, Parameter)
python
def getParameters(self): """ Get all the parameters declared. """ parameters = lock_and_call( lambda: self._impl.getParameters(), self._lock ) return EntityMap(parameters, Parameter)
[ "def", "getParameters", "(", "self", ")", ":", "parameters", "=", "lock_and_call", "(", "lambda", ":", "self", ".", "_impl", ".", "getParameters", "(", ")", ",", "self", ".", "_lock", ")", "return", "EntityMap", "(", "parameters", ",", "Parameter", ")" ]
Get all the parameters declared.
[ "Get", "all", "the", "parameters", "declared", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L839-L847
ampl/amplpy
amplpy/ampl.py
AMPL.getCurrentObjective
def getCurrentObjective(self): """ Get the the current objective. Returns `None` if no objective is set. """ name = self._impl.getCurrentObjectiveName() if name == '': return None else: return self.getObjective(name)
python
def getCurrentObjective(self): """ Get the the current objective. Returns `None` if no objective is set. """ name = self._impl.getCurrentObjectiveName() if name == '': return None else: return self.getObjective(name)
[ "def", "getCurrentObjective", "(", "self", ")", ":", "name", "=", "self", ".", "_impl", ".", "getCurrentObjectiveName", "(", ")", "if", "name", "==", "''", ":", "return", "None", "else", ":", "return", "self", ".", "getObjective", "(", "name", ")" ]
Get the the current objective. Returns `None` if no objective is set.
[ "Get", "the", "the", "current", "objective", ".", "Returns", "None", "if", "no", "objective", "is", "set", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L849-L857
ampl/amplpy
amplpy/ampl.py
AMPL._var
def _var(self): """ Get/Set a variable. """ class Variables(object): def __getitem__(_self, name): return self.getVariable(name) def __setitem__(_self, name, value): self.getVariable(name).setValue(value) def __iter__(...
python
def _var(self): """ Get/Set a variable. """ class Variables(object): def __getitem__(_self, name): return self.getVariable(name) def __setitem__(_self, name, value): self.getVariable(name).setValue(value) def __iter__(...
[ "def", "_var", "(", "self", ")", ":", "class", "Variables", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getVariable", "(", "name", ")", "def", "__setitem__", "(", "_self", ",", "name", "...
Get/Set a variable.
[ "Get", "/", "Set", "a", "variable", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L859-L873
ampl/amplpy
amplpy/ampl.py
AMPL._con
def _con(self): """ Get/Set a constraint. """ class Constraints(object): def __getitem__(_self, name): return self.getConstraint(name) def __setitem__(_self, name, value): self.getConstraint(name).setDual(value) def __...
python
def _con(self): """ Get/Set a constraint. """ class Constraints(object): def __getitem__(_self, name): return self.getConstraint(name) def __setitem__(_self, name, value): self.getConstraint(name).setDual(value) def __...
[ "def", "_con", "(", "self", ")", ":", "class", "Constraints", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getConstraint", "(", "name", ")", "def", "__setitem__", "(", "_self", ",", "name",...
Get/Set a constraint.
[ "Get", "/", "Set", "a", "constraint", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L875-L889
ampl/amplpy
amplpy/ampl.py
AMPL._obj
def _obj(self): """ Get an objective. """ class Objectives(object): def __getitem__(_self, name): return self.getObjective(name) def __iter__(_self): return self.getObjectives() return Objectives()
python
def _obj(self): """ Get an objective. """ class Objectives(object): def __getitem__(_self, name): return self.getObjective(name) def __iter__(_self): return self.getObjectives() return Objectives()
[ "def", "_obj", "(", "self", ")", ":", "class", "Objectives", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getObjective", "(", "name", ")", "def", "__iter__", "(", "_self", ")", ":", "retu...
Get an objective.
[ "Get", "an", "objective", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L891-L902
ampl/amplpy
amplpy/ampl.py
AMPL._set
def _set(self): """ Get/Set a set. """ class Sets(object): def __getitem__(_self, name): return self.getSet(name) def __setitem__(_self, name, values): self.getSet(name).setValues(values) def __iter__(_self): ...
python
def _set(self): """ Get/Set a set. """ class Sets(object): def __getitem__(_self, name): return self.getSet(name) def __setitem__(_self, name, values): self.getSet(name).setValues(values) def __iter__(_self): ...
[ "def", "_set", "(", "self", ")", ":", "class", "Sets", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getSet", "(", "name", ")", "def", "__setitem__", "(", "_self", ",", "name", ",", "val...
Get/Set a set.
[ "Get", "/", "Set", "a", "set", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L904-L918
ampl/amplpy
amplpy/ampl.py
AMPL._param
def _param(self): """ Get/Set a parameter. """ class Parameters(object): def __getitem__(_self, name): return self.getParameter(name) def __setitem__(_self, name, value): if isinstance(value, (float, int, basestring)): ...
python
def _param(self): """ Get/Set a parameter. """ class Parameters(object): def __getitem__(_self, name): return self.getParameter(name) def __setitem__(_self, name, value): if isinstance(value, (float, int, basestring)): ...
[ "def", "_param", "(", "self", ")", ":", "class", "Parameters", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getParameter", "(", "name", ")", "def", "__setitem__", "(", "_self", ",", "name",...
Get/Set a parameter.
[ "Get", "/", "Set", "a", "parameter", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L920-L937
ampl/amplpy
amplpy/ampl.py
AMPL._option
def _option(self): """ Get/Set an option. """ class Options(object): def __getitem__(_self, name): return self.getOption(name) def __setitem__(_self, name, value): self.setOption(name, value) return Options()
python
def _option(self): """ Get/Set an option. """ class Options(object): def __getitem__(_self, name): return self.getOption(name) def __setitem__(_self, name, value): self.setOption(name, value) return Options()
[ "def", "_option", "(", "self", ")", ":", "class", "Options", "(", "object", ")", ":", "def", "__getitem__", "(", "_self", ",", "name", ")", ":", "return", "self", ".", "getOption", "(", "name", ")", "def", "__setitem__", "(", "_self", ",", "name", ",...
Get/Set an option.
[ "Get", "/", "Set", "an", "option", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L939-L950
ampl/amplpy
amplpy/ampl.py
AMPL.exportData
def exportData(self, datfile): """ Create a .dat file with the data that has been loaded. Args: datfile: Path to the file (Relative to the current working directory or absolute). """ def ampl_set(name, values): def format_entry(e): ...
python
def exportData(self, datfile): """ Create a .dat file with the data that has been loaded. Args: datfile: Path to the file (Relative to the current working directory or absolute). """ def ampl_set(name, values): def format_entry(e): ...
[ "def", "exportData", "(", "self", ",", "datfile", ")", ":", "def", "ampl_set", "(", "name", ",", "values", ")", ":", "def", "format_entry", "(", "e", ")", ":", "return", "repr", "(", "e", ")", ".", "replace", "(", "' '", ",", "''", ")", "return", ...
Create a .dat file with the data that has been loaded. Args: datfile: Path to the file (Relative to the current working directory or absolute).
[ "Create", "a", ".", "dat", "file", "with", "the", "data", "that", "has", "been", "loaded", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L959-L1003
ampl/amplpy
amplpy/ampl.py
AMPL.exportGurobiModel
def exportGurobiModel(self, gurobiDriver='gurobi', verbose=False): """ Export the model to Gurobi as a gurobipy.Model object. Args: gurobiDriver: The name or the path of the Gurobi solver driver. verbose: Whether should generate verbose output. Returns: ...
python
def exportGurobiModel(self, gurobiDriver='gurobi', verbose=False): """ Export the model to Gurobi as a gurobipy.Model object. Args: gurobiDriver: The name or the path of the Gurobi solver driver. verbose: Whether should generate verbose output. Returns: ...
[ "def", "exportGurobiModel", "(", "self", ",", "gurobiDriver", "=", "'gurobi'", ",", "verbose", "=", "False", ")", ":", "from", "gurobipy", "import", "GRB", ",", "read", "from", "tempfile", "import", "mkdtemp", "from", "shutil", "import", "rmtree", "from", "o...
Export the model to Gurobi as a gurobipy.Model object. Args: gurobiDriver: The name or the path of the Gurobi solver driver. verbose: Whether should generate verbose output. Returns: A :class:`gurobipy.Model` object with the model loaded.
[ "Export", "the", "model", "to", "Gurobi", "as", "a", "gurobipy", ".", "Model", "object", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L1005-L1068
ampl/amplpy
amplpy/ampl.py
AMPL.importGurobiSolution
def importGurobiSolution(self, grbmodel): """ Import the solution from a gurobipy.Model object. Args: grbmodel: A :class:`gurobipy.Model` object with the model solved. """ self.eval(''.join( 'let {} := {};'.format(var.VarName, var.X) for var i...
python
def importGurobiSolution(self, grbmodel): """ Import the solution from a gurobipy.Model object. Args: grbmodel: A :class:`gurobipy.Model` object with the model solved. """ self.eval(''.join( 'let {} := {};'.format(var.VarName, var.X) for var i...
[ "def", "importGurobiSolution", "(", "self", ",", "grbmodel", ")", ":", "self", ".", "eval", "(", "''", ".", "join", "(", "'let {} := {};'", ".", "format", "(", "var", ".", "VarName", ",", "var", ".", "X", ")", "for", "var", "in", "grbmodel", ".", "ge...
Import the solution from a gurobipy.Model object. Args: grbmodel: A :class:`gurobipy.Model` object with the model solved.
[ "Import", "the", "solution", "from", "a", "gurobipy", ".", "Model", "object", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L1070-L1081
ampl/amplpy
amplpy/ampl.py
AMPL._startRecording
def _startRecording(self, filename): """ Start recording the session to a file for debug purposes. """ self.setOption('_log_file_name', filename) self.setOption('_log_input_only', True) self.setOption('_log', True)
python
def _startRecording(self, filename): """ Start recording the session to a file for debug purposes. """ self.setOption('_log_file_name', filename) self.setOption('_log_input_only', True) self.setOption('_log', True)
[ "def", "_startRecording", "(", "self", ",", "filename", ")", ":", "self", ".", "setOption", "(", "'_log_file_name'", ",", "filename", ")", "self", ".", "setOption", "(", "'_log_input_only'", ",", "True", ")", "self", ".", "setOption", "(", "'_log'", ",", "...
Start recording the session to a file for debug purposes.
[ "Start", "recording", "the", "session", "to", "a", "file", "for", "debug", "purposes", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L1084-L1090
ampl/amplpy
amplpy/ampl.py
AMPL._loadSession
def _loadSession(self, filename): """ Load a recorded session. """ try: self.eval(open(filename).read()) except RuntimeError as e: print(e)
python
def _loadSession(self, filename): """ Load a recorded session. """ try: self.eval(open(filename).read()) except RuntimeError as e: print(e)
[ "def", "_loadSession", "(", "self", ",", "filename", ")", ":", "try", ":", "self", ".", "eval", "(", "open", "(", "filename", ")", ".", "read", "(", ")", ")", "except", "RuntimeError", "as", "e", ":", "print", "(", "e", ")" ]
Load a recorded session.
[ "Load", "a", "recorded", "session", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/ampl.py#L1098-L1105
ampl/amplpy
setup.py
ls_dir
def ls_dir(base_dir): """List files recursively.""" return [ os.path.join(dirpath.replace(base_dir, '', 1), f) for (dirpath, dirnames, files) in os.walk(base_dir) for f in files ]
python
def ls_dir(base_dir): """List files recursively.""" return [ os.path.join(dirpath.replace(base_dir, '', 1), f) for (dirpath, dirnames, files) in os.walk(base_dir) for f in files ]
[ "def", "ls_dir", "(", "base_dir", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "dirpath", ".", "replace", "(", "base_dir", ",", "''", ",", "1", ")", ",", "f", ")", "for", "(", "dirpath", ",", "dirnames", ",", "files", ")", "in", ...
List files recursively.
[ "List", "files", "recursively", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/setup.py#L45-L51
ampl/amplpy
amplpy/entity.py
Entity.get
def get(self, *index): """ Get the instance with the specified index. Returns: The corresponding instance. """ assert self.wrapFunction is not None if len(index) == 1 and isinstance(index[0], (tuple, list)): index = index[0] if len(index) ...
python
def get(self, *index): """ Get the instance with the specified index. Returns: The corresponding instance. """ assert self.wrapFunction is not None if len(index) == 1 and isinstance(index[0], (tuple, list)): index = index[0] if len(index) ...
[ "def", "get", "(", "self", ",", "*", "index", ")", ":", "assert", "self", ".", "wrapFunction", "is", "not", "None", "if", "len", "(", "index", ")", "==", "1", "and", "isinstance", "(", "index", "[", "0", "]", ",", "(", "tuple", ",", "list", ")", ...
Get the instance with the specified index. Returns: The corresponding instance.
[ "Get", "the", "instance", "with", "the", "specified", "index", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/entity.py#L60-L73
ampl/amplpy
amplpy/entity.py
Entity.find
def find(self, *index): """ Searches the current entity for an instance with the specified index. Returns: The wanted instance if found, otherwise it returns `None`. """ assert self.wrapFunction is not None if len(index) == 1 and isinstance(index[0], (tuple, ...
python
def find(self, *index): """ Searches the current entity for an instance with the specified index. Returns: The wanted instance if found, otherwise it returns `None`. """ assert self.wrapFunction is not None if len(index) == 1 and isinstance(index[0], (tuple, ...
[ "def", "find", "(", "self", ",", "*", "index", ")", ":", "assert", "self", ".", "wrapFunction", "is", "not", "None", "if", "len", "(", "index", ")", "==", "1", "and", "isinstance", "(", "index", "[", "0", "]", ",", "(", "tuple", ",", "list", ")",...
Searches the current entity for an instance with the specified index. Returns: The wanted instance if found, otherwise it returns `None`.
[ "Searches", "the", "current", "entity", "for", "an", "instance", "with", "the", "specified", "index", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/entity.py#L75-L89
ampl/amplpy
amplpy/entity.py
Entity.getValues
def getValues(self, suffixes=None): """ If a list of suffixes is provided, get the specified suffixes value for all instances. Otherwise, get all the principal values of this entity. The specific returned value depends on the type of entity (see list below). For: - Varia...
python
def getValues(self, suffixes=None): """ If a list of suffixes is provided, get the specified suffixes value for all instances. Otherwise, get all the principal values of this entity. The specific returned value depends on the type of entity (see list below). For: - Varia...
[ "def", "getValues", "(", "self", ",", "suffixes", "=", "None", ")", ":", "if", "suffixes", "is", "None", ":", "return", "DataFrame", ".", "_fromDataFrameRef", "(", "self", ".", "_impl", ".", "getValues", "(", ")", ")", "else", ":", "suffixes", "=", "li...
If a list of suffixes is provided, get the specified suffixes value for all instances. Otherwise, get all the principal values of this entity. The specific returned value depends on the type of entity (see list below). For: - Variables and Objectives it returns the suffix ``val``. ...
[ "If", "a", "list", "of", "suffixes", "is", "provided", "get", "the", "specified", "suffixes", "value", "for", "all", "instances", ".", "Otherwise", "get", "all", "the", "principal", "values", "of", "this", "entity", ".", "The", "specific", "returned", "value...
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/entity.py#L152-L175
ampl/amplpy
amplpy/entity.py
Entity.setValues
def setValues(self, data): """ Set the values of this entiy to the correponding values of a DataFrame indexed over the same sets (or a subset). This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In ...
python
def setValues(self, data): """ Set the values of this entiy to the correponding values of a DataFrame indexed over the same sets (or a subset). This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In ...
[ "def", "setValues", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "DataFrame", ")", ":", "self", ".", "_impl", ".", "setValuesDf", "(", "data", ".", "_impl", ")", "else", ":", "if", "pd", "is", "not", "None", "and", "isi...
Set the values of this entiy to the correponding values of a DataFrame indexed over the same sets (or a subset). This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In particular, the statement: .. code-blo...
[ "Set", "the", "values", "of", "this", "entiy", "to", "the", "correponding", "values", "of", "a", "DataFrame", "indexed", "over", "the", "same", "sets", "(", "or", "a", "subset", ")", ".", "This", "function", "assigns", "the", "values", "in", "the", "firs...
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/entity.py#L177-L205
ampl/amplpy
amplpy/dataframe.py
DataFrame.addRow
def addRow(self, *value): """ Add a row to the DataFrame. The size of the tuple must be equal to the total number of columns in the dataframe. Args: value: A single argument with a tuple containing all the values for the row to be added, or multiple arguments ...
python
def addRow(self, *value): """ Add a row to the DataFrame. The size of the tuple must be equal to the total number of columns in the dataframe. Args: value: A single argument with a tuple containing all the values for the row to be added, or multiple arguments ...
[ "def", "addRow", "(", "self", ",", "*", "value", ")", ":", "if", "len", "(", "value", ")", "==", "1", "and", "isinstance", "(", "value", "[", "0", "]", ",", "(", "tuple", ",", "list", ")", ")", ":", "value", "=", "value", "[", "0", "]", "asse...
Add a row to the DataFrame. The size of the tuple must be equal to the total number of columns in the dataframe. Args: value: A single argument with a tuple containing all the values for the row to be added, or multiple arguments with the values for each column.
[ "Add", "a", "row", "to", "the", "DataFrame", ".", "The", "size", "of", "the", "tuple", "must", "be", "equal", "to", "the", "total", "number", "of", "columns", "in", "the", "dataframe", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L155-L168
ampl/amplpy
amplpy/dataframe.py
DataFrame.addColumn
def addColumn(self, header, values=[]): """ Add a new column with the corresponding header and values to the dataframe. Args: header: The name of the new column. values: A list of size :func:`~amplpy.DataFrame.getNumRows` with all the values of the n...
python
def addColumn(self, header, values=[]): """ Add a new column with the corresponding header and values to the dataframe. Args: header: The name of the new column. values: A list of size :func:`~amplpy.DataFrame.getNumRows` with all the values of the n...
[ "def", "addColumn", "(", "self", ",", "header", ",", "values", "=", "[", "]", ")", ":", "if", "len", "(", "values", ")", "==", "0", ":", "self", ".", "_impl", ".", "addColumn", "(", "header", ")", "else", ":", "assert", "len", "(", "values", ")",...
Add a new column with the corresponding header and values to the dataframe. Args: header: The name of the new column. values: A list of size :func:`~amplpy.DataFrame.getNumRows` with all the values of the new column.
[ "Add", "a", "new", "column", "with", "the", "corresponding", "header", "and", "values", "to", "the", "dataframe", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L170-L192
ampl/amplpy
amplpy/dataframe.py
DataFrame.setColumn
def setColumn(self, header, values): """ Set the values of a column. Args: header: The header of the column to be set. values: The values to set. """ if any(isinstance(value, basestring) for value in values): values = list(map(str, values)) ...
python
def setColumn(self, header, values): """ Set the values of a column. Args: header: The header of the column to be set. values: The values to set. """ if any(isinstance(value, basestring) for value in values): values = list(map(str, values)) ...
[ "def", "setColumn", "(", "self", ",", "header", ",", "values", ")", ":", "if", "any", "(", "isinstance", "(", "value", ",", "basestring", ")", "for", "value", "in", "values", ")", ":", "values", "=", "list", "(", "map", "(", "str", ",", "values", "...
Set the values of a column. Args: header: The header of the column to be set. values: The values to set.
[ "Set", "the", "values", "of", "a", "column", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L203-L220
ampl/amplpy
amplpy/dataframe.py
DataFrame.getRow
def getRow(self, key): """ Get a row by value of the indexing columns. If the index is not specified, gets the only row of a dataframe with no indexing columns. Args: key: Tuple representing the index of the desired row. Returns: The row. """ ...
python
def getRow(self, key): """ Get a row by value of the indexing columns. If the index is not specified, gets the only row of a dataframe with no indexing columns. Args: key: Tuple representing the index of the desired row. Returns: The row. """ ...
[ "def", "getRow", "(", "self", ",", "key", ")", ":", "return", "Row", "(", "self", ".", "_impl", ".", "getRow", "(", "Tuple", "(", "key", ")", ".", "_impl", ")", ")" ]
Get a row by value of the indexing columns. If the index is not specified, gets the only row of a dataframe with no indexing columns. Args: key: Tuple representing the index of the desired row. Returns: The row.
[ "Get", "a", "row", "by", "value", "of", "the", "indexing", "columns", ".", "If", "the", "index", "is", "not", "specified", "gets", "the", "only", "row", "of", "a", "dataframe", "with", "no", "indexing", "columns", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L222-L233
ampl/amplpy
amplpy/dataframe.py
DataFrame.getRowByIndex
def getRowByIndex(self, index): """ Get row by numeric index. Args: index: Zero-based index of the row to get. Returns: The corresponding row. """ assert isinstance(index, int) return Row(self._impl.getRowByIndex(index))
python
def getRowByIndex(self, index): """ Get row by numeric index. Args: index: Zero-based index of the row to get. Returns: The corresponding row. """ assert isinstance(index, int) return Row(self._impl.getRowByIndex(index))
[ "def", "getRowByIndex", "(", "self", ",", "index", ")", ":", "assert", "isinstance", "(", "index", ",", "int", ")", "return", "Row", "(", "self", ".", "_impl", ".", "getRowByIndex", "(", "index", ")", ")" ]
Get row by numeric index. Args: index: Zero-based index of the row to get. Returns: The corresponding row.
[ "Get", "row", "by", "numeric", "index", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L235-L246
ampl/amplpy
amplpy/dataframe.py
DataFrame.getHeaders
def getHeaders(self): """ Get the headers of this DataFrame. Returns: The headers of this DataFrame. """ headers = self._impl.getHeaders() return tuple( headers.getIndex(i) for i in range(self._impl.getNumCols()) )
python
def getHeaders(self): """ Get the headers of this DataFrame. Returns: The headers of this DataFrame. """ headers = self._impl.getHeaders() return tuple( headers.getIndex(i) for i in range(self._impl.getNumCols()) )
[ "def", "getHeaders", "(", "self", ")", ":", "headers", "=", "self", ".", "_impl", ".", "getHeaders", "(", ")", "return", "tuple", "(", "headers", ".", "getIndex", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "_impl", ".", "getNumCols",...
Get the headers of this DataFrame. Returns: The headers of this DataFrame.
[ "Get", "the", "headers", "of", "this", "DataFrame", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L248-L258
ampl/amplpy
amplpy/dataframe.py
DataFrame.setValues
def setValues(self, values): """ Set the values of a DataFrame from a dictionary. Args: values: Dictionary with the values to set. """ ncols = self.getNumCols() nindices = self.getNumIndices() for key, value in values.items(): key = Utils....
python
def setValues(self, values): """ Set the values of a DataFrame from a dictionary. Args: values: Dictionary with the values to set. """ ncols = self.getNumCols() nindices = self.getNumIndices() for key, value in values.items(): key = Utils....
[ "def", "setValues", "(", "self", ",", "values", ")", ":", "ncols", "=", "self", ".", "getNumCols", "(", ")", "nindices", "=", "self", ".", "getNumIndices", "(", ")", "for", "key", ",", "value", "in", "values", ".", "items", "(", ")", ":", "key", "=...
Set the values of a DataFrame from a dictionary. Args: values: Dictionary with the values to set.
[ "Set", "the", "values", "of", "a", "DataFrame", "from", "a", "dictionary", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L260-L274
ampl/amplpy
amplpy/dataframe.py
DataFrame.toDict
def toDict(self): """ Return a dictionary with the DataFrame data. """ d = {} nindices = self.getNumIndices() for i in range(self.getNumRows()): row = list(self.getRowByIndex(i)) if nindices > 1: key = tuple(row[:nindices]) ...
python
def toDict(self): """ Return a dictionary with the DataFrame data. """ d = {} nindices = self.getNumIndices() for i in range(self.getNumRows()): row = list(self.getRowByIndex(i)) if nindices > 1: key = tuple(row[:nindices]) ...
[ "def", "toDict", "(", "self", ")", ":", "d", "=", "{", "}", "nindices", "=", "self", ".", "getNumIndices", "(", ")", "for", "i", "in", "range", "(", "self", ".", "getNumRows", "(", ")", ")", ":", "row", "=", "list", "(", "self", ".", "getRowByInd...
Return a dictionary with the DataFrame data.
[ "Return", "a", "dictionary", "with", "the", "DataFrame", "data", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L276-L296
ampl/amplpy
amplpy/dataframe.py
DataFrame.toList
def toList(self): """ Return a list with the DataFrame data. """ if self.getNumCols() > 1: return [ tuple(self.getRowByIndex(i)) for i in range(self.getNumRows()) ] else: return [ self.getRowByInd...
python
def toList(self): """ Return a list with the DataFrame data. """ if self.getNumCols() > 1: return [ tuple(self.getRowByIndex(i)) for i in range(self.getNumRows()) ] else: return [ self.getRowByInd...
[ "def", "toList", "(", "self", ")", ":", "if", "self", ".", "getNumCols", "(", ")", ">", "1", ":", "return", "[", "tuple", "(", "self", ".", "getRowByIndex", "(", "i", ")", ")", "for", "i", "in", "range", "(", "self", ".", "getNumRows", "(", ")", ...
Return a list with the DataFrame data.
[ "Return", "a", "list", "with", "the", "DataFrame", "data", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L298-L311
ampl/amplpy
amplpy/dataframe.py
DataFrame.toPandas
def toPandas(self): """ Return a pandas DataFrame with the DataFrame data. """ assert pd is not None nindices = self.getNumIndices() headers = self.getHeaders() columns = { header: list(self.getColumn(header)) for header in headers[nindices...
python
def toPandas(self): """ Return a pandas DataFrame with the DataFrame data. """ assert pd is not None nindices = self.getNumIndices() headers = self.getHeaders() columns = { header: list(self.getColumn(header)) for header in headers[nindices...
[ "def", "toPandas", "(", "self", ")", ":", "assert", "pd", "is", "not", "None", "nindices", "=", "self", ".", "getNumIndices", "(", ")", "headers", "=", "self", ".", "getHeaders", "(", ")", "columns", "=", "{", "header", ":", "list", "(", "self", ".",...
Return a pandas DataFrame with the DataFrame data.
[ "Return", "a", "pandas", "DataFrame", "with", "the", "DataFrame", "data", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L313-L332
ampl/amplpy
amplpy/dataframe.py
DataFrame.fromPandas
def fromPandas(cls, df): """ Create a :class:`~amplpy.DataFrame` from a pandas DataFrame. """ assert pd is not None if isinstance(df, pd.Series): df = pd.DataFrame(df) else: assert isinstance(df, pd.DataFrame) keys = [ key if is...
python
def fromPandas(cls, df): """ Create a :class:`~amplpy.DataFrame` from a pandas DataFrame. """ assert pd is not None if isinstance(df, pd.Series): df = pd.DataFrame(df) else: assert isinstance(df, pd.DataFrame) keys = [ key if is...
[ "def", "fromPandas", "(", "cls", ",", "df", ")", ":", "assert", "pd", "is", "not", "None", "if", "isinstance", "(", "df", ",", "pd", ".", "Series", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "df", ")", "else", ":", "assert", "isinstance", ...
Create a :class:`~amplpy.DataFrame` from a pandas DataFrame.
[ "Create", "a", ":", "class", ":", "~amplpy", ".", "DataFrame", "from", "a", "pandas", "DataFrame", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L335-L356
ampl/amplpy
amplpy/dataframe.py
DataFrame.fromNumpy
def fromNumpy(cls, data): """ Create a :class:`~amplpy.DataFrame` from a numpy array or matrix. """ assert np is not None if isinstance(data, np.ndarray): index = [] if len(data.shape) == 1: columns = [('value', data.tolist())] ...
python
def fromNumpy(cls, data): """ Create a :class:`~amplpy.DataFrame` from a numpy array or matrix. """ assert np is not None if isinstance(data, np.ndarray): index = [] if len(data.shape) == 1: columns = [('value', data.tolist())] ...
[ "def", "fromNumpy", "(", "cls", ",", "data", ")", ":", "assert", "np", "is", "not", "None", "if", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", ":", "index", "=", "[", "]", "if", "len", "(", "data", ".", "shape", ")", "==", "1", ":...
Create a :class:`~amplpy.DataFrame` from a numpy array or matrix.
[ "Create", "a", ":", "class", ":", "~amplpy", ".", "DataFrame", "from", "a", "numpy", "array", "or", "matrix", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/dataframe.py#L359-L377
ampl/amplpy
amplpy/parameter.py
Parameter.set
def set(self, *args): """ Set the value of a single instance of this parameter. Args: args: value if the parameter is scalar, index and value otherwise. Raises: RuntimeError: If the entity has been deleted in the underlying AMPL. ...
python
def set(self, *args): """ Set the value of a single instance of this parameter. Args: args: value if the parameter is scalar, index and value otherwise. Raises: RuntimeError: If the entity has been deleted in the underlying AMPL. ...
[ "def", "set", "(", "self", ",", "*", "args", ")", ":", "assert", "len", "(", "args", ")", "in", "(", "1", ",", "2", ")", "if", "len", "(", "args", ")", "==", "1", ":", "value", "=", "args", "[", "0", "]", "self", ".", "_impl", ".", "set", ...
Set the value of a single instance of this parameter. Args: args: value if the parameter is scalar, index and value otherwise. Raises: RuntimeError: If the entity has been deleted in the underlying AMPL. TypeError: If the parameter is not sc...
[ "Set", "the", "value", "of", "a", "single", "instance", "of", "this", "parameter", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/parameter.py#L70-L96
ampl/amplpy
amplpy/parameter.py
Parameter.setValues
def setValues(self, values): """ Assign the values (string or float) to the parameter instances with the specified indices, equivalent to the AMPL code: .. code-block:: ampl let {i in indices} par[i] := values[i]; Args: values: list, dictionary or :clas...
python
def setValues(self, values): """ Assign the values (string or float) to the parameter instances with the specified indices, equivalent to the AMPL code: .. code-block:: ampl let {i in indices} par[i] := values[i]; Args: values: list, dictionary or :clas...
[ "def", "setValues", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "indices", ",", "values", "=", "list", "(", "zip", "(", "*", "values", ".", "items", "(", ")", ")", ")", "indices", "=", "Utils", ...
Assign the values (string or float) to the parameter instances with the specified indices, equivalent to the AMPL code: .. code-block:: ampl let {i in indices} par[i] := values[i]; Args: values: list, dictionary or :class:`~amplpy.DataFrame` with the indice...
[ "Assign", "the", "values", "(", "string", "or", "float", ")", "to", "the", "parameter", "instances", "with", "the", "specified", "indices", "equivalent", "to", "the", "AMPL", "code", ":" ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/parameter.py#L98-L138
ampl/amplpy
amplpy/set.py
Set.setValues
def setValues(self, values): """ Set the tuples in this set. Valid only for non-indexed sets. Args: values: A list of tuples or a :class:`~amplpy.DataFrame`. In the case of a :class:`~amplpy.DataFrame`, the number of indexing columns of the must be equal to the arit...
python
def setValues(self, values): """ Set the tuples in this set. Valid only for non-indexed sets. Args: values: A list of tuples or a :class:`~amplpy.DataFrame`. In the case of a :class:`~amplpy.DataFrame`, the number of indexing columns of the must be equal to the arit...
[ "def", "setValues", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "list", ",", "set", ")", ")", ":", "if", "any", "(", "isinstance", "(", "value", ",", "basestring", ")", "for", "value", "in", "values", ")", ":"...
Set the tuples in this set. Valid only for non-indexed sets. Args: values: A list of tuples or a :class:`~amplpy.DataFrame`. In the case of a :class:`~amplpy.DataFrame`, the number of indexing columns of the must be equal to the arity of the set. In the case of a list of tu...
[ "Set", "the", "tuples", "in", "this", "set", ".", "Valid", "only", "for", "non", "-", "indexed", "sets", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/set.py#L80-L123
ampl/amplpy
amplpy/errorhandler.py
ErrorHandler.error
def error(self, amplexception): """ Receives notification of an error. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Error:\n{:s}'.format(msg)) raise amplexception
python
def error(self, amplexception): """ Receives notification of an error. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Error:\n{:s}'.format(msg)) raise amplexception
[ "def", "error", "(", "self", ",", "amplexception", ")", ":", "msg", "=", "'\\t'", "+", "str", "(", "amplexception", ")", ".", "replace", "(", "'\\n'", ",", "'\\n\\t'", ")", "print", "(", "'Error:\\n{:s}'", ".", "format", "(", "msg", ")", ")", "raise", ...
Receives notification of an error.
[ "Receives", "notification", "of", "an", "error", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/errorhandler.py#L18-L24
ampl/amplpy
amplpy/errorhandler.py
ErrorHandler.warning
def warning(self, amplexception): """ Receives notification of a warning. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Warning:\n{:s}'.format(msg))
python
def warning(self, amplexception): """ Receives notification of a warning. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Warning:\n{:s}'.format(msg))
[ "def", "warning", "(", "self", ",", "amplexception", ")", ":", "msg", "=", "'\\t'", "+", "str", "(", "amplexception", ")", ".", "replace", "(", "'\\n'", ",", "'\\n\\t'", ")", "print", "(", "'Warning:\\n{:s}'", ".", "format", "(", "msg", ")", ")" ]
Receives notification of a warning.
[ "Receives", "notification", "of", "a", "warning", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/errorhandler.py#L26-L31
ampl/amplpy
amplpy/utils.py
register_magics
def register_magics(store_name='_ampl_cells', ampl_object=None): """ Register jupyter notebook magics ``%%ampl`` and ``%%ampl_eval``. Args: store_name: Name of the store where ``%%ampl cells`` will be stored. ampl_object: Object used to evaluate ``%%ampl_eval`` cells. """ from IPyth...
python
def register_magics(store_name='_ampl_cells', ampl_object=None): """ Register jupyter notebook magics ``%%ampl`` and ``%%ampl_eval``. Args: store_name: Name of the store where ``%%ampl cells`` will be stored. ampl_object: Object used to evaluate ``%%ampl_eval`` cells. """ from IPyth...
[ "def", "register_magics", "(", "store_name", "=", "'_ampl_cells'", ",", "ampl_object", "=", "None", ")", ":", "from", "IPython", ".", "core", ".", "magic", "import", "(", "Magics", ",", "magics_class", ",", "cell_magic", ",", "line_magic", ")", "@", "magics_...
Register jupyter notebook magics ``%%ampl`` and ``%%ampl_eval``. Args: store_name: Name of the store where ``%%ampl cells`` will be stored. ampl_object: Object used to evaluate ``%%ampl_eval`` cells.
[ "Register", "jupyter", "notebook", "magics", "%%ampl", "and", "%%ampl_eval", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/utils.py#L11-L45
ampl/amplpy
amplpy/variable.py
Variable.fix
def fix(self, value=None): """ Fix all instances of this variable to a value if provided or to their current value otherwise. Args: value: value to be set. """ if value is None: self._impl.fix() else: self._impl.fix(value)
python
def fix(self, value=None): """ Fix all instances of this variable to a value if provided or to their current value otherwise. Args: value: value to be set. """ if value is None: self._impl.fix() else: self._impl.fix(value)
[ "def", "fix", "(", "self", ",", "value", "=", "None", ")", ":", "if", "value", "is", "None", ":", "self", ".", "_impl", ".", "fix", "(", ")", "else", ":", "self", ".", "_impl", ".", "fix", "(", "value", ")" ]
Fix all instances of this variable to a value if provided or to their current value otherwise. Args: value: value to be set.
[ "Fix", "all", "instances", "of", "this", "variable", "to", "a", "value", "if", "provided", "or", "to", "their", "current", "value", "otherwise", "." ]
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/variable.py#L38-L50
eventable/vobject
vobject/base.py
toVName
def toVName(name, stripNum=0, upper=False): """ Turn a Python name into an iCalendar style name, optionally uppercase and with characters stripped off. """ if upper: name = name.upper() if stripNum != 0: name = name[:-stripNum] return name.replace('_', '-')
python
def toVName(name, stripNum=0, upper=False): """ Turn a Python name into an iCalendar style name, optionally uppercase and with characters stripped off. """ if upper: name = name.upper() if stripNum != 0: name = name[:-stripNum] return name.replace('_', '-')
[ "def", "toVName", "(", "name", ",", "stripNum", "=", "0", ",", "upper", "=", "False", ")", ":", "if", "upper", ":", "name", "=", "name", ".", "upper", "(", ")", "if", "stripNum", "!=", "0", ":", "name", "=", "name", "[", ":", "-", "stripNum", "...
Turn a Python name into an iCalendar style name, optionally uppercase and with characters stripped off.
[ "Turn", "a", "Python", "name", "into", "an", "iCalendar", "style", "name", "optionally", "uppercase", "and", "with", "characters", "stripped", "off", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L261-L270
eventable/vobject
vobject/base.py
parseParams
def parseParams(string): """ Parse parameters """ all = params_re.findall(string) allParameters = [] for tup in all: paramList = [tup[0]] # tup looks like (name, valuesString) for pair in param_values_re.findall(tup[1]): # pair looks like ('', value) or (value, '') ...
python
def parseParams(string): """ Parse parameters """ all = params_re.findall(string) allParameters = [] for tup in all: paramList = [tup[0]] # tup looks like (name, valuesString) for pair in param_values_re.findall(tup[1]): # pair looks like ('', value) or (value, '') ...
[ "def", "parseParams", "(", "string", ")", ":", "all", "=", "params_re", ".", "findall", "(", "string", ")", "allParameters", "=", "[", "]", "for", "tup", "in", "all", ":", "paramList", "=", "[", "tup", "[", "0", "]", "]", "# tup looks like (name, valuesS...
Parse parameters
[ "Parse", "parameters" ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L789-L804
eventable/vobject
vobject/base.py
parseLine
def parseLine(line, lineNumber=None): """ Parse line """ match = line_re.match(line) if match is None: raise ParseError("Failed to parse line: {0!s}".format(line), lineNumber) # Underscores are replaced with dash to work around Lotus Notes return (match.group('name').replace('_', '-'...
python
def parseLine(line, lineNumber=None): """ Parse line """ match = line_re.match(line) if match is None: raise ParseError("Failed to parse line: {0!s}".format(line), lineNumber) # Underscores are replaced with dash to work around Lotus Notes return (match.group('name').replace('_', '-'...
[ "def", "parseLine", "(", "line", ",", "lineNumber", "=", "None", ")", ":", "match", "=", "line_re", ".", "match", "(", "line", ")", "if", "match", "is", "None", ":", "raise", "ParseError", "(", "\"Failed to parse line: {0!s}\"", ".", "format", "(", "line",...
Parse line
[ "Parse", "line" ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L807-L817
eventable/vobject
vobject/base.py
dquoteEscape
def dquoteEscape(param): """ Return param, or "param" if ',' or ';' or ':' is in param. """ if param.find('"') >= 0: raise VObjectError("Double quotes aren't allowed in parameter values.") for char in ',;:': if param.find(char) >= 0: return '"' + param + '"' return pa...
python
def dquoteEscape(param): """ Return param, or "param" if ',' or ';' or ':' is in param. """ if param.find('"') >= 0: raise VObjectError("Double quotes aren't allowed in parameter values.") for char in ',;:': if param.find(char) >= 0: return '"' + param + '"' return pa...
[ "def", "dquoteEscape", "(", "param", ")", ":", "if", "param", ".", "find", "(", "'\"'", ")", ">=", "0", ":", "raise", "VObjectError", "(", "\"Double quotes aren't allowed in parameter values.\"", ")", "for", "char", "in", "',;:'", ":", "if", "param", ".", "f...
Return param, or "param" if ',' or ';' or ':' is in param.
[ "Return", "param", "or", "param", "if", "or", ";", "or", ":", "is", "in", "param", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L929-L938
eventable/vobject
vobject/base.py
readComponents
def readComponents(streamOrString, validate=False, transform=True, ignoreUnreadable=False, allowQP=False): """ Generate one Component at a time from a stream. """ if isinstance(streamOrString, basestring): stream = six.StringIO(streamOrString) else: stream = stream...
python
def readComponents(streamOrString, validate=False, transform=True, ignoreUnreadable=False, allowQP=False): """ Generate one Component at a time from a stream. """ if isinstance(streamOrString, basestring): stream = six.StringIO(streamOrString) else: stream = stream...
[ "def", "readComponents", "(", "streamOrString", ",", "validate", "=", "False", ",", "transform", "=", "True", ",", "ignoreUnreadable", "=", "False", ",", "allowQP", "=", "False", ")", ":", "if", "isinstance", "(", "streamOrString", ",", "basestring", ")", ":...
Generate one Component at a time from a stream.
[ "Generate", "one", "Component", "at", "a", "time", "from", "a", "stream", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L1075-L1147
eventable/vobject
vobject/base.py
readOne
def readOne(stream, validate=False, transform=True, ignoreUnreadable=False, allowQP=False): """ Return the first component from stream. """ return next(readComponents(stream, validate, transform, ignoreUnreadable, allowQP))
python
def readOne(stream, validate=False, transform=True, ignoreUnreadable=False, allowQP=False): """ Return the first component from stream. """ return next(readComponents(stream, validate, transform, ignoreUnreadable, allowQP))
[ "def", "readOne", "(", "stream", ",", "validate", "=", "False", ",", "transform", "=", "True", ",", "ignoreUnreadable", "=", "False", ",", "allowQP", "=", "False", ")", ":", "return", "next", "(", "readComponents", "(", "stream", ",", "validate", ",", "t...
Return the first component from stream.
[ "Return", "the", "first", "component", "from", "stream", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L1150-L1156
eventable/vobject
vobject/base.py
registerBehavior
def registerBehavior(behavior, name=None, default=False, id=None): """ Register the given behavior. If default is True (or if this is the first version registered with this name), the version will be the default if no id is given. """ if not name: name = behavior.name.upper() if id ...
python
def registerBehavior(behavior, name=None, default=False, id=None): """ Register the given behavior. If default is True (or if this is the first version registered with this name), the version will be the default if no id is given. """ if not name: name = behavior.name.upper() if id ...
[ "def", "registerBehavior", "(", "behavior", ",", "name", "=", "None", ",", "default", "=", "False", ",", "id", "=", "None", ")", ":", "if", "not", "name", ":", "name", "=", "behavior", ".", "name", ".", "upper", "(", ")", "if", "id", "is", "None", ...
Register the given behavior. If default is True (or if this is the first version registered with this name), the version will be the default if no id is given.
[ "Register", "the", "given", "behavior", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L1163-L1180
eventable/vobject
vobject/base.py
getBehavior
def getBehavior(name, id=None): """ Return a matching behavior if it exists, or None. If id is None, return the default for name. """ name = name.upper() if name in __behaviorRegistry: if id: for n, behavior in __behaviorRegistry[name]: if n == id: ...
python
def getBehavior(name, id=None): """ Return a matching behavior if it exists, or None. If id is None, return the default for name. """ name = name.upper() if name in __behaviorRegistry: if id: for n, behavior in __behaviorRegistry[name]: if n == id: ...
[ "def", "getBehavior", "(", "name", ",", "id", "=", "None", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "if", "name", "in", "__behaviorRegistry", ":", "if", "id", ":", "for", "n", ",", "behavior", "in", "__behaviorRegistry", "[", "name", "]...
Return a matching behavior if it exists, or None. If id is None, return the default for name.
[ "Return", "a", "matching", "behavior", "if", "it", "exists", "or", "None", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L1183-L1197
eventable/vobject
vobject/base.py
VBase.validate
def validate(self, *args, **kwds): """ Call the behavior's validate method, or return True. """ if self.behavior: return self.behavior.validate(self, *args, **kwds) return True
python
def validate(self, *args, **kwds): """ Call the behavior's validate method, or return True. """ if self.behavior: return self.behavior.validate(self, *args, **kwds) return True
[ "def", "validate", "(", "self", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "if", "self", ".", "behavior", ":", "return", "self", ".", "behavior", ".", "validate", "(", "self", ",", "*", "args", ",", "*", "*", "kwds", ")", "return", "True"...
Call the behavior's validate method, or return True.
[ "Call", "the", "behavior", "s", "validate", "method", "or", "return", "True", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L119-L125
eventable/vobject
vobject/base.py
VBase.autoBehavior
def autoBehavior(self, cascade=False): """ Set behavior if name is in self.parentBehavior.knownChildren. If cascade is True, unset behavior and parentBehavior for all descendants, then recalculate behavior and parentBehavior. """ parentBehavior = self.parentBehavior ...
python
def autoBehavior(self, cascade=False): """ Set behavior if name is in self.parentBehavior.knownChildren. If cascade is True, unset behavior and parentBehavior for all descendants, then recalculate behavior and parentBehavior. """ parentBehavior = self.parentBehavior ...
[ "def", "autoBehavior", "(", "self", ",", "cascade", "=", "False", ")", ":", "parentBehavior", "=", "self", ".", "parentBehavior", "if", "parentBehavior", "is", "not", "None", ":", "knownChildTup", "=", "parentBehavior", ".", "knownChildren", ".", "get", "(", ...
Set behavior if name is in self.parentBehavior.knownChildren. If cascade is True, unset behavior and parentBehavior for all descendants, then recalculate behavior and parentBehavior.
[ "Set", "behavior", "if", "name", "is", "in", "self", ".", "parentBehavior", ".", "knownChildren", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L141-L160
eventable/vobject
vobject/base.py
VBase.setBehavior
def setBehavior(self, behavior, cascade=True): """ Set behavior. If cascade is True, autoBehavior all descendants. """ self.behavior = behavior if cascade: for obj in self.getChildren(): obj.parentBehavior = behavior obj.autoBehavior(Tr...
python
def setBehavior(self, behavior, cascade=True): """ Set behavior. If cascade is True, autoBehavior all descendants. """ self.behavior = behavior if cascade: for obj in self.getChildren(): obj.parentBehavior = behavior obj.autoBehavior(Tr...
[ "def", "setBehavior", "(", "self", ",", "behavior", ",", "cascade", "=", "True", ")", ":", "self", ".", "behavior", "=", "behavior", "if", "cascade", ":", "for", "obj", "in", "self", ".", "getChildren", "(", ")", ":", "obj", ".", "parentBehavior", "=",...
Set behavior. If cascade is True, autoBehavior all descendants.
[ "Set", "behavior", ".", "If", "cascade", "is", "True", "autoBehavior", "all", "descendants", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L162-L170
eventable/vobject
vobject/base.py
VBase.transformToNative
def transformToNative(self): """ Transform this object into a custom VBase subclass. transformToNative should always return a representation of this object. It may do so by modifying self in place then returning self, or by creating a new object. """ if self.isNa...
python
def transformToNative(self): """ Transform this object into a custom VBase subclass. transformToNative should always return a representation of this object. It may do so by modifying self in place then returning self, or by creating a new object. """ if self.isNa...
[ "def", "transformToNative", "(", "self", ")", ":", "if", "self", ".", "isNative", "or", "not", "self", ".", "behavior", "or", "not", "self", ".", "behavior", ".", "hasNative", ":", "return", "self", "else", ":", "self_orig", "=", "copy", ".", "copy", "...
Transform this object into a custom VBase subclass. transformToNative should always return a representation of this object. It may do so by modifying self in place then returning self, or by creating a new object.
[ "Transform", "this", "object", "into", "a", "custom", "VBase", "subclass", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L172-L198
eventable/vobject
vobject/base.py
VBase.serialize
def serialize(self, buf=None, lineLength=75, validate=True, behavior=None): """ Serialize to buf if it exists, otherwise return a string. Use self.behavior.serialize if behavior exists. """ if not behavior: behavior = self.behavior if behavior: i...
python
def serialize(self, buf=None, lineLength=75, validate=True, behavior=None): """ Serialize to buf if it exists, otherwise return a string. Use self.behavior.serialize if behavior exists. """ if not behavior: behavior = self.behavior if behavior: i...
[ "def", "serialize", "(", "self", ",", "buf", "=", "None", ",", "lineLength", "=", "75", ",", "validate", "=", "True", ",", "behavior", "=", "None", ")", ":", "if", "not", "behavior", ":", "behavior", "=", "self", ".", "behavior", "if", "behavior", ":...
Serialize to buf if it exists, otherwise return a string. Use self.behavior.serialize if behavior exists.
[ "Serialize", "to", "buf", "if", "it", "exists", "otherwise", "return", "a", "string", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L242-L258
eventable/vobject
vobject/base.py
ContentLine.valueRepr
def valueRepr(self): """ Transform the representation of the value according to the behavior, if any. """ v = self.value if self.behavior: v = self.behavior.valueRepr(self) return v
python
def valueRepr(self): """ Transform the representation of the value according to the behavior, if any. """ v = self.value if self.behavior: v = self.behavior.valueRepr(self) return v
[ "def", "valueRepr", "(", "self", ")", ":", "v", "=", "self", ".", "value", "if", "self", ".", "behavior", ":", "v", "=", "self", ".", "behavior", ".", "valueRepr", "(", "self", ")", "return", "v" ]
Transform the representation of the value according to the behavior, if any.
[ "Transform", "the", "representation", "of", "the", "value", "according", "to", "the", "behavior", "if", "any", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L419-L427
eventable/vobject
vobject/base.py
Component.setProfile
def setProfile(self, name): """ Assign a PROFILE to this unnamed component. Used by vCard, not by vCalendar. """ if self.name or self.useBegin: if self.name == name: return raise VObjectError("This component already has a PROFILE or " ...
python
def setProfile(self, name): """ Assign a PROFILE to this unnamed component. Used by vCard, not by vCalendar. """ if self.name or self.useBegin: if self.name == name: return raise VObjectError("This component already has a PROFILE or " ...
[ "def", "setProfile", "(", "self", ",", "name", ")", ":", "if", "self", ".", "name", "or", "self", ".", "useBegin", ":", "if", "self", ".", "name", "==", "name", ":", "return", "raise", "VObjectError", "(", "\"This component already has a PROFILE or \"", "\"u...
Assign a PROFILE to this unnamed component. Used by vCard, not by vCalendar.
[ "Assign", "a", "PROFILE", "to", "this", "unnamed", "component", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L501-L512
eventable/vobject
vobject/base.py
Component.getChildValue
def getChildValue(self, childName, default=None, childNumber=0): """ Return a child's value (the first, by default), or None. """ child = self.contents.get(toVName(childName)) if child is None: return default else: return child[childNumber].value
python
def getChildValue(self, childName, default=None, childNumber=0): """ Return a child's value (the first, by default), or None. """ child = self.contents.get(toVName(childName)) if child is None: return default else: return child[childNumber].value
[ "def", "getChildValue", "(", "self", ",", "childName", ",", "default", "=", "None", ",", "childNumber", "=", "0", ")", ":", "child", "=", "self", ".", "contents", ".", "get", "(", "toVName", "(", "childName", ")", ")", "if", "child", "is", "None", ":...
Return a child's value (the first, by default), or None.
[ "Return", "a", "child", "s", "value", "(", "the", "first", "by", "default", ")", "or", "None", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L570-L578
eventable/vobject
vobject/base.py
Component.add
def add(self, objOrName, group=None): """ Add objOrName to contents, set behavior if it can be inferred. If objOrName is a string, create an empty component or line based on behavior. If no behavior is found for the object, add a ContentLine. group is an optional prefix to the ...
python
def add(self, objOrName, group=None): """ Add objOrName to contents, set behavior if it can be inferred. If objOrName is a string, create an empty component or line based on behavior. If no behavior is found for the object, add a ContentLine. group is an optional prefix to the ...
[ "def", "add", "(", "self", ",", "objOrName", ",", "group", "=", "None", ")", ":", "if", "isinstance", "(", "objOrName", ",", "VBase", ")", ":", "obj", "=", "objOrName", "if", "self", ".", "behavior", ":", "obj", ".", "parentBehavior", "=", "self", "....
Add objOrName to contents, set behavior if it can be inferred. If objOrName is a string, create an empty component or line based on behavior. If no behavior is found for the object, add a ContentLine. group is an optional prefix to the name of the object (see RFC 2425).
[ "Add", "objOrName", "to", "contents", "set", "behavior", "if", "it", "can", "be", "inferred", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L580-L612
eventable/vobject
vobject/base.py
Component.remove
def remove(self, obj): """ Remove obj from contents. """ named = self.contents.get(obj.name.lower()) if named: try: named.remove(obj) if len(named) == 0: del self.contents[obj.name.lower()] except ValueEr...
python
def remove(self, obj): """ Remove obj from contents. """ named = self.contents.get(obj.name.lower()) if named: try: named.remove(obj) if len(named) == 0: del self.contents[obj.name.lower()] except ValueEr...
[ "def", "remove", "(", "self", ",", "obj", ")", ":", "named", "=", "self", ".", "contents", ".", "get", "(", "obj", ".", "name", ".", "lower", "(", ")", ")", "if", "named", ":", "try", ":", "named", ".", "remove", "(", "obj", ")", "if", "len", ...
Remove obj from contents.
[ "Remove", "obj", "from", "contents", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L614-L625
eventable/vobject
vobject/base.py
Component.setBehaviorFromVersionLine
def setBehaviorFromVersionLine(self, versionLine): """ Set behavior if one matches name, versionLine.value. """ v = getBehavior(self.name, versionLine.value) if v: self.setBehavior(v)
python
def setBehaviorFromVersionLine(self, versionLine): """ Set behavior if one matches name, versionLine.value. """ v = getBehavior(self.name, versionLine.value) if v: self.setBehavior(v)
[ "def", "setBehaviorFromVersionLine", "(", "self", ",", "versionLine", ")", ":", "v", "=", "getBehavior", "(", "self", ".", "name", ",", "versionLine", ".", "value", ")", "if", "v", ":", "self", ".", "setBehavior", "(", "v", ")" ]
Set behavior if one matches name, versionLine.value.
[ "Set", "behavior", "if", "one", "matches", "name", "versionLine", ".", "value", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L657-L663
eventable/vobject
vobject/base.py
Component.transformChildrenToNative
def transformChildrenToNative(self): """ Recursively replace children with their native representation. Sort to get dependency order right, like vtimezone before vevent. """ for childArray in (self.contents[k] for k in self.sortChildKeys()): for child in childArray: ...
python
def transformChildrenToNative(self): """ Recursively replace children with their native representation. Sort to get dependency order right, like vtimezone before vevent. """ for childArray in (self.contents[k] for k in self.sortChildKeys()): for child in childArray: ...
[ "def", "transformChildrenToNative", "(", "self", ")", ":", "for", "childArray", "in", "(", "self", ".", "contents", "[", "k", "]", "for", "k", "in", "self", ".", "sortChildKeys", "(", ")", ")", ":", "for", "child", "in", "childArray", ":", "child", "="...
Recursively replace children with their native representation. Sort to get dependency order right, like vtimezone before vevent.
[ "Recursively", "replace", "children", "with", "their", "native", "representation", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L665-L674
eventable/vobject
vobject/base.py
Component.transformChildrenFromNative
def transformChildrenFromNative(self, clearBehavior=True): """ Recursively transform native children to vanilla representations. """ for childArray in self.contents.values(): for child in childArray: child = child.transformFromNative() child.tr...
python
def transformChildrenFromNative(self, clearBehavior=True): """ Recursively transform native children to vanilla representations. """ for childArray in self.contents.values(): for child in childArray: child = child.transformFromNative() child.tr...
[ "def", "transformChildrenFromNative", "(", "self", ",", "clearBehavior", "=", "True", ")", ":", "for", "childArray", "in", "self", ".", "contents", ".", "values", "(", ")", ":", "for", "child", "in", "childArray", ":", "child", "=", "child", ".", "transfor...
Recursively transform native children to vanilla representations.
[ "Recursively", "transform", "native", "children", "to", "vanilla", "representations", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/base.py#L676-L686
eventable/vobject
vobject/hcalendar.py
HCalendar.serialize
def serialize(cls, obj, buf=None, lineLength=None, validate=True): """ Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar) """ outbuf = buf or six.StringIO() level = 0 # holds current indentation level tabwidth = 3 ...
python
def serialize(cls, obj, buf=None, lineLength=None, validate=True): """ Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar) """ outbuf = buf or six.StringIO() level = 0 # holds current indentation level tabwidth = 3 ...
[ "def", "serialize", "(", "cls", ",", "obj", ",", "buf", "=", "None", ",", "lineLength", "=", "None", ",", "validate", "=", "True", ")", ":", "outbuf", "=", "buf", "or", "six", ".", "StringIO", "(", ")", "level", "=", "0", "# holds current indentation l...
Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar)
[ "Serialize", "iCalendar", "to", "HTML", "using", "the", "hCalendar", "microformat", "(", "http", ":", "//", "microformats", ".", "org", "/", "wiki", "/", "hcalendar", ")" ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/vobject/hcalendar.py#L43-L128
eventable/vobject
docs/build/lib/vobject/change_tz.py
change_tz
def change_tz(cal, new_timezone, default, utc_only=False, utc_tz=icalendar.utc): """ Change the timezone of the specified component. Args: cal (Component): the component to change new_timezone (tzinfo): the timezone to change to default (tzinfo): a timezone to assume if the dtstart ...
python
def change_tz(cal, new_timezone, default, utc_only=False, utc_tz=icalendar.utc): """ Change the timezone of the specified component. Args: cal (Component): the component to change new_timezone (tzinfo): the timezone to change to default (tzinfo): a timezone to assume if the dtstart ...
[ "def", "change_tz", "(", "cal", ",", "new_timezone", ",", "default", ",", "utc_only", "=", "False", ",", "utc_tz", "=", "icalendar", ".", "utc", ")", ":", "for", "vevent", "in", "getattr", "(", "cal", ",", "'vevent_list'", ",", "[", "]", ")", ":", "s...
Change the timezone of the specified component. Args: cal (Component): the component to change new_timezone (tzinfo): the timezone to change to default (tzinfo): a timezone to assume if the dtstart or dtend in cal doesn't have an existing timezone utc_only (bool): only ...
[ "Change", "the", "timezone", "of", "the", "specified", "component", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/change_tz.py#L13-L37
eventable/vobject
docs/build/lib/vobject/base.py
foldOneLine
def foldOneLine(outbuf, input, lineLength = 75): """ Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines TO-DO: This all seems odd. Is it still needed, especially in python3? """ if len(input) < lineLength: # Optimize for unfolded line case ...
python
def foldOneLine(outbuf, input, lineLength = 75): """ Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines TO-DO: This all seems odd. Is it still needed, especially in python3? """ if len(input) < lineLength: # Optimize for unfolded line case ...
[ "def", "foldOneLine", "(", "outbuf", ",", "input", ",", "lineLength", "=", "75", ")", ":", "if", "len", "(", "input", ")", "<", "lineLength", ":", "# Optimize for unfolded line case", "try", ":", "outbuf", ".", "write", "(", "bytes", "(", "input", ",", "...
Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines TO-DO: This all seems odd. Is it still needed, especially in python3?
[ "Folding", "line", "procedure", "that", "ensures", "multi", "-", "byte", "utf", "-", "8", "sequences", "are", "not", "broken", "across", "lines" ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/base.py#L927-L974
eventable/vobject
docs/build/lib/vobject/base.py
defaultSerialize
def defaultSerialize(obj, buf, lineLength): """ Encode and fold obj and its children, write to buf or return a string. """ outbuf = buf or six.StringIO() if isinstance(obj, Component): if obj.group is None: groupString = '' else: groupString = obj.group + '.'...
python
def defaultSerialize(obj, buf, lineLength): """ Encode and fold obj and its children, write to buf or return a string. """ outbuf = buf or six.StringIO() if isinstance(obj, Component): if obj.group is None: groupString = '' else: groupString = obj.group + '.'...
[ "def", "defaultSerialize", "(", "obj", ",", "buf", ",", "lineLength", ")", ":", "outbuf", "=", "buf", "or", "six", ".", "StringIO", "(", ")", "if", "isinstance", "(", "obj", ",", "Component", ")", ":", "if", "obj", ".", "group", "is", "None", ":", ...
Encode and fold obj and its children, write to buf or return a string.
[ "Encode", "and", "fold", "obj", "and", "its", "children", "write", "to", "buf", "or", "return", "a", "string", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/base.py#L977-L1017
eventable/vobject
docs/build/lib/vobject/icalendar.py
toUnicode
def toUnicode(s): """ Take a string or unicode, turn it into unicode, decoding as utf-8 """ if isinstance(s, six.binary_type): s = s.decode('utf-8') return s
python
def toUnicode(s): """ Take a string or unicode, turn it into unicode, decoding as utf-8 """ if isinstance(s, six.binary_type): s = s.decode('utf-8') return s
[ "def", "toUnicode", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "binary_type", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", "return", "s" ]
Take a string or unicode, turn it into unicode, decoding as utf-8
[ "Take", "a", "string", "or", "unicode", "turn", "it", "into", "unicode", "decoding", "as", "utf", "-", "8" ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L54-L60
eventable/vobject
docs/build/lib/vobject/icalendar.py
numToDigits
def numToDigits(num, places): """ Helper, for converting numbers to textual digits. """ s = str(num) if len(s) < places: return ("0" * (places - len(s))) + s elif len(s) > places: return s[len(s)-places: ] else: return s
python
def numToDigits(num, places): """ Helper, for converting numbers to textual digits. """ s = str(num) if len(s) < places: return ("0" * (places - len(s))) + s elif len(s) > places: return s[len(s)-places: ] else: return s
[ "def", "numToDigits", "(", "num", ",", "places", ")", ":", "s", "=", "str", "(", "num", ")", "if", "len", "(", "s", ")", "<", "places", ":", "return", "(", "\"0\"", "*", "(", "places", "-", "len", "(", "s", ")", ")", ")", "+", "s", "elif", ...
Helper, for converting numbers to textual digits.
[ "Helper", "for", "converting", "numbers", "to", "textual", "digits", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1503-L1513
eventable/vobject
docs/build/lib/vobject/icalendar.py
timedeltaToString
def timedeltaToString(delta): """ Convert timedelta to an ical DURATION. """ if delta.days == 0: sign = 1 else: sign = delta.days / abs(delta.days) delta = abs(delta) days = delta.days hours = int(delta.seconds / 3600) minutes = int((delta.seconds % 3600) / 60) se...
python
def timedeltaToString(delta): """ Convert timedelta to an ical DURATION. """ if delta.days == 0: sign = 1 else: sign = delta.days / abs(delta.days) delta = abs(delta) days = delta.days hours = int(delta.seconds / 3600) minutes = int((delta.seconds % 3600) / 60) se...
[ "def", "timedeltaToString", "(", "delta", ")", ":", "if", "delta", ".", "days", "==", "0", ":", "sign", "=", "1", "else", ":", "sign", "=", "delta", ".", "days", "/", "abs", "(", "delta", ".", "days", ")", "delta", "=", "abs", "(", "delta", ")", ...
Convert timedelta to an ical DURATION.
[ "Convert", "timedelta", "to", "an", "ical", "DURATION", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1515-L1545
eventable/vobject
docs/build/lib/vobject/icalendar.py
stringToTextValues
def stringToTextValues(s, listSeparator=',', charList=None, strict=False): """ Returns list of strings. """ if charList is None: charList = escapableCharList def escapableChar (c): return c in charList def error(msg): if strict: raise ParseError(msg) ...
python
def stringToTextValues(s, listSeparator=',', charList=None, strict=False): """ Returns list of strings. """ if charList is None: charList = escapableCharList def escapableChar (c): return c in charList def error(msg): if strict: raise ParseError(msg) ...
[ "def", "stringToTextValues", "(", "s", ",", "listSeparator", "=", "','", ",", "charList", "=", "None", ",", "strict", "=", "False", ")", ":", "if", "charList", "is", "None", ":", "charList", "=", "escapableCharList", "def", "escapableChar", "(", "c", ")", ...
Returns list of strings.
[ "Returns", "list", "of", "strings", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1636-L1702
eventable/vobject
docs/build/lib/vobject/icalendar.py
stringToDurations
def stringToDurations(s, strict=False): """ Returns list of timedelta objects. """ def makeTimedelta(sign, week, day, hour, minute, sec): if sign == "-": sign = -1 else: sign = 1 week = int(week) day = int(day) hour = int(hour) minute = int(minute) ...
python
def stringToDurations(s, strict=False): """ Returns list of timedelta objects. """ def makeTimedelta(sign, week, day, hour, minute, sec): if sign == "-": sign = -1 else: sign = 1 week = int(week) day = int(day) hour = int(hour) minute = int(minute) ...
[ "def", "stringToDurations", "(", "s", ",", "strict", "=", "False", ")", ":", "def", "makeTimedelta", "(", "sign", ",", "week", ",", "day", ",", "hour", ",", "minute", ",", "sec", ")", ":", "if", "sign", "==", "\"-\"", ":", "sign", "=", "-", "1", ...
Returns list of timedelta objects.
[ "Returns", "list", "of", "timedelta", "objects", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1705-L1820
eventable/vobject
docs/build/lib/vobject/icalendar.py
parseDtstart
def parseDtstart(contentline, allowSignatureMismatch=False): """ Convert a contentline's value into a date or date-time. A variety of clients don't serialize dates with the appropriate VALUE parameter, so rather than failing on these (technically invalid) lines, if allowSignatureMismatch is True, t...
python
def parseDtstart(contentline, allowSignatureMismatch=False): """ Convert a contentline's value into a date or date-time. A variety of clients don't serialize dates with the appropriate VALUE parameter, so rather than failing on these (technically invalid) lines, if allowSignatureMismatch is True, t...
[ "def", "parseDtstart", "(", "contentline", ",", "allowSignatureMismatch", "=", "False", ")", ":", "tzinfo", "=", "getTzid", "(", "getattr", "(", "contentline", ",", "'tzid_param'", ",", "None", ")", ")", "valueParam", "=", "getattr", "(", "contentline", ",", ...
Convert a contentline's value into a date or date-time. A variety of clients don't serialize dates with the appropriate VALUE parameter, so rather than failing on these (technically invalid) lines, if allowSignatureMismatch is True, try to parse both varieties.
[ "Convert", "a", "contentline", "s", "value", "into", "a", "date", "or", "date", "-", "time", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1823-L1842
eventable/vobject
docs/build/lib/vobject/icalendar.py
getTransition
def getTransition(transitionTo, year, tzinfo): """ Return the datetime of the transition to/from DST, or None. """ def firstTransition(iterDates, test): """ Return the last date not matching test, or None if all tests matched. """ success = None for dt in iterDate...
python
def getTransition(transitionTo, year, tzinfo): """ Return the datetime of the transition to/from DST, or None. """ def firstTransition(iterDates, test): """ Return the last date not matching test, or None if all tests matched. """ success = None for dt in iterDate...
[ "def", "getTransition", "(", "transitionTo", ",", "year", ",", "tzinfo", ")", ":", "def", "firstTransition", "(", "iterDates", ",", "test", ")", ":", "\"\"\"\n Return the last date not matching test, or None if all tests matched.\n \"\"\"", "success", "=", "No...
Return the datetime of the transition to/from DST, or None.
[ "Return", "the", "datetime", "of", "the", "transition", "to", "/", "from", "DST", "or", "None", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1855-L1927
eventable/vobject
docs/build/lib/vobject/icalendar.py
tzinfo_eq
def tzinfo_eq(tzinfo1, tzinfo2, startYear = 2000, endYear=2020): """ Compare offsets and DST transitions from startYear to endYear. """ if tzinfo1 == tzinfo2: return True elif tzinfo1 is None or tzinfo2 is None: return False def dt_test(dt): if dt is None: re...
python
def tzinfo_eq(tzinfo1, tzinfo2, startYear = 2000, endYear=2020): """ Compare offsets and DST transitions from startYear to endYear. """ if tzinfo1 == tzinfo2: return True elif tzinfo1 is None or tzinfo2 is None: return False def dt_test(dt): if dt is None: re...
[ "def", "tzinfo_eq", "(", "tzinfo1", ",", "tzinfo2", ",", "startYear", "=", "2000", ",", "endYear", "=", "2020", ")", ":", "if", "tzinfo1", "==", "tzinfo2", ":", "return", "True", "elif", "tzinfo1", "is", "None", "or", "tzinfo2", "is", "None", ":", "ret...
Compare offsets and DST transitions from startYear to endYear.
[ "Compare", "offsets", "and", "DST", "transitions", "from", "startYear", "to", "endYear", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1929-L1951
eventable/vobject
docs/build/lib/vobject/icalendar.py
TimezoneComponent.registerTzinfo
def registerTzinfo(obj, tzinfo): """ Register tzinfo if it's not already registered, return its tzid. """ tzid = obj.pickTzid(tzinfo) if tzid and not getTzid(tzid, False): registerTzid(tzid, tzinfo) return tzid
python
def registerTzinfo(obj, tzinfo): """ Register tzinfo if it's not already registered, return its tzid. """ tzid = obj.pickTzid(tzinfo) if tzid and not getTzid(tzid, False): registerTzid(tzid, tzinfo) return tzid
[ "def", "registerTzinfo", "(", "obj", ",", "tzinfo", ")", ":", "tzid", "=", "obj", ".", "pickTzid", "(", "tzinfo", ")", "if", "tzid", "and", "not", "getTzid", "(", "tzid", ",", "False", ")", ":", "registerTzid", "(", "tzid", ",", "tzinfo", ")", "retur...
Register tzinfo if it's not already registered, return its tzid.
[ "Register", "tzinfo", "if", "it", "s", "not", "already", "registered", "return", "its", "tzid", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L121-L128
eventable/vobject
docs/build/lib/vobject/icalendar.py
TimezoneComponent.settzinfo
def settzinfo(self, tzinfo, start=2000, end=2030): """ Create appropriate objects in self to represent tzinfo. Collapse DST transitions to rrules as much as possible. Assumptions: - DST <-> Standard transitions occur on the hour - never within a month of one another ...
python
def settzinfo(self, tzinfo, start=2000, end=2030): """ Create appropriate objects in self to represent tzinfo. Collapse DST transitions to rrules as much as possible. Assumptions: - DST <-> Standard transitions occur on the hour - never within a month of one another ...
[ "def", "settzinfo", "(", "self", ",", "tzinfo", ",", "start", "=", "2000", ",", "end", "=", "2030", ")", ":", "def", "fromLastWeek", "(", "dt", ")", ":", "\"\"\"\n How many weeks from the end of the month dt is, starting from 1.\n \"\"\"", "weekDel...
Create appropriate objects in self to represent tzinfo. Collapse DST transitions to rrules as much as possible. Assumptions: - DST <-> Standard transitions occur on the hour - never within a month of one another - twice or fewer times a year - never in the month of Dece...
[ "Create", "appropriate", "objects", "in", "self", "to", "represent", "tzinfo", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L152-L318
eventable/vobject
docs/build/lib/vobject/icalendar.py
TimezoneComponent.pickTzid
def pickTzid(tzinfo, allowUTC=False): """ Given a tzinfo class, use known APIs to determine TZID, or use tzname. """ if tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)): # If tzinfo is UTC, we don't need a TZID return None # try PyICU's tzid key...
python
def pickTzid(tzinfo, allowUTC=False): """ Given a tzinfo class, use known APIs to determine TZID, or use tzname. """ if tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)): # If tzinfo is UTC, we don't need a TZID return None # try PyICU's tzid key...
[ "def", "pickTzid", "(", "tzinfo", ",", "allowUTC", "=", "False", ")", ":", "if", "tzinfo", "is", "None", "or", "(", "not", "allowUTC", "and", "tzinfo_eq", "(", "tzinfo", ",", "utc", ")", ")", ":", "# If tzinfo is UTC, we don't need a TZID", "return", "None",...
Given a tzinfo class, use known APIs to determine TZID, or use tzname.
[ "Given", "a", "tzinfo", "class", "use", "known", "APIs", "to", "determine", "TZID", "or", "use", "tzname", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L325-L352
eventable/vobject
docs/build/lib/vobject/icalendar.py
TextBehavior.decode
def decode(cls, line): """ Remove backslash escaping from line.value. """ if line.encoded: encoding = getattr(line, 'encoding_param', None) if encoding and encoding.upper() == cls.base64string: line.value = codecs.decode(self.value.encode("utf-8"),...
python
def decode(cls, line): """ Remove backslash escaping from line.value. """ if line.encoded: encoding = getattr(line, 'encoding_param', None) if encoding and encoding.upper() == cls.base64string: line.value = codecs.decode(self.value.encode("utf-8"),...
[ "def", "decode", "(", "cls", ",", "line", ")", ":", "if", "line", ".", "encoded", ":", "encoding", "=", "getattr", "(", "line", ",", "'encoding_param'", ",", "None", ")", "if", "encoding", "and", "encoding", ".", "upper", "(", ")", "==", "cls", ".", ...
Remove backslash escaping from line.value.
[ "Remove", "backslash", "escaping", "from", "line", ".", "value", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L629-L639
eventable/vobject
docs/build/lib/vobject/icalendar.py
RecurringBehavior.transformToNative
def transformToNative(obj): """ Turn a recurring Component into a RecurringComponent. """ if not obj.isNative: object.__setattr__(obj, '__class__', RecurringComponent) obj.isNative = True return obj
python
def transformToNative(obj): """ Turn a recurring Component into a RecurringComponent. """ if not obj.isNative: object.__setattr__(obj, '__class__', RecurringComponent) obj.isNative = True return obj
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "not", "obj", ".", "isNative", ":", "object", ".", "__setattr__", "(", "obj", ",", "'__class__'", ",", "RecurringComponent", ")", "obj", ".", "isNative", "=", "True", "return", "obj" ]
Turn a recurring Component into a RecurringComponent.
[ "Turn", "a", "recurring", "Component", "into", "a", "RecurringComponent", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L667-L674
eventable/vobject
docs/build/lib/vobject/icalendar.py
RecurringBehavior.generateImplicitParameters
def generateImplicitParameters(obj): """ Generate a UID if one does not exist. This is just a dummy implementation, for now. """ if not hasattr(obj, 'uid'): rand = int(random.random() * 100000) now = datetime.datetime.now(utc) now = dateTimeTo...
python
def generateImplicitParameters(obj): """ Generate a UID if one does not exist. This is just a dummy implementation, for now. """ if not hasattr(obj, 'uid'): rand = int(random.random() * 100000) now = datetime.datetime.now(utc) now = dateTimeTo...
[ "def", "generateImplicitParameters", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'uid'", ")", ":", "rand", "=", "int", "(", "random", ".", "random", "(", ")", "*", "100000", ")", "now", "=", "datetime", ".", "datetime", ".", "now"...
Generate a UID if one does not exist. This is just a dummy implementation, for now.
[ "Generate", "a", "UID", "if", "one", "does", "not", "exist", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L684-L696
eventable/vobject
docs/build/lib/vobject/icalendar.py
DateOrDateTimeBehavior.transformToNative
def transformToNative(obj): """ Turn obj.value into a date or datetime. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': return obj obj.value=obj.value obj.value=parseDtstart(obj, allowSignatureMismatch=True) ...
python
def transformToNative(obj): """ Turn obj.value into a date or datetime. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': return obj obj.value=obj.value obj.value=parseDtstart(obj, allowSignatureMismatch=True) ...
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "return", "obj", "obj", ".", "isNative", "=", "True", "if", "obj", ".", "value", "==", "''", ":", "return", "obj", "obj", ".", "value", "=", "obj", ".", "value", "...
Turn obj.value into a date or datetime.
[ "Turn", "obj", ".", "value", "into", "a", "date", "or", "datetime", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L762-L778
eventable/vobject
docs/build/lib/vobject/icalendar.py
DateOrDateTimeBehavior.transformFromNative
def transformFromNative(obj): """ Replace the date or datetime in obj.value with an ISO 8601 string. """ if type(obj.value) == datetime.date: obj.isNative = False obj.value_param = 'DATE' obj.value = dateToString(obj.value) return obj ...
python
def transformFromNative(obj): """ Replace the date or datetime in obj.value with an ISO 8601 string. """ if type(obj.value) == datetime.date: obj.isNative = False obj.value_param = 'DATE' obj.value = dateToString(obj.value) return obj ...
[ "def", "transformFromNative", "(", "obj", ")", ":", "if", "type", "(", "obj", ".", "value", ")", "==", "datetime", ".", "date", ":", "obj", ".", "isNative", "=", "False", "obj", ".", "value_param", "=", "'DATE'", "obj", ".", "value", "=", "dateToString...
Replace the date or datetime in obj.value with an ISO 8601 string.
[ "Replace", "the", "date", "or", "datetime", "in", "obj", ".", "value", "with", "an", "ISO", "8601", "string", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L781-L791
eventable/vobject
docs/build/lib/vobject/icalendar.py
MultiDateBehavior.transformToNative
def transformToNative(obj): """ Turn obj.value into a list of dates, datetimes, or (datetime, timedelta) tuples. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': obj.value = [] return obj tzinfo = ...
python
def transformToNative(obj): """ Turn obj.value into a list of dates, datetimes, or (datetime, timedelta) tuples. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': obj.value = [] return obj tzinfo = ...
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "return", "obj", "obj", ".", "isNative", "=", "True", "if", "obj", ".", "value", "==", "''", ":", "obj", ".", "value", "=", "[", "]", "return", "obj", "tzinfo", "=...
Turn obj.value into a list of dates, datetimes, or (datetime, timedelta) tuples.
[ "Turn", "obj", ".", "value", "into", "a", "list", "of", "dates", "datetimes", "or", "(", "datetime", "timedelta", ")", "tuples", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L802-L822
eventable/vobject
docs/build/lib/vobject/icalendar.py
MultiDateBehavior.transformFromNative
def transformFromNative(obj): """ Replace the date, datetime or period tuples in obj.value with appropriate strings. """ if obj.value and type(obj.value[0]) == datetime.date: obj.isNative = False obj.value_param = 'DATE' obj.value = ','.join([d...
python
def transformFromNative(obj): """ Replace the date, datetime or period tuples in obj.value with appropriate strings. """ if obj.value and type(obj.value[0]) == datetime.date: obj.isNative = False obj.value_param = 'DATE' obj.value = ','.join([d...
[ "def", "transformFromNative", "(", "obj", ")", ":", "if", "obj", ".", "value", "and", "type", "(", "obj", ".", "value", "[", "0", "]", ")", "==", "datetime", ".", "date", ":", "obj", ".", "isNative", "=", "False", "obj", ".", "value_param", "=", "'...
Replace the date, datetime or period tuples in obj.value with appropriate strings.
[ "Replace", "the", "date", "datetime", "or", "period", "tuples", "in", "obj", ".", "value", "with", "appropriate", "strings", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L825-L848
eventable/vobject
docs/build/lib/vobject/icalendar.py
MultiTextBehavior.decode
def decode(cls, line): """ Remove backslash escaping from line.value, then split on commas. """ if line.encoded: line.value = stringToTextValues(line.value, listSeparator=cls.listSeparator) line.encoded=False
python
def decode(cls, line): """ Remove backslash escaping from line.value, then split on commas. """ if line.encoded: line.value = stringToTextValues(line.value, listSeparator=cls.listSeparator) line.encoded=False
[ "def", "decode", "(", "cls", ",", "line", ")", ":", "if", "line", ".", "encoded", ":", "line", ".", "value", "=", "stringToTextValues", "(", "line", ".", "value", ",", "listSeparator", "=", "cls", ".", "listSeparator", ")", "line", ".", "encoded", "=",...
Remove backslash escaping from line.value, then split on commas.
[ "Remove", "backslash", "escaping", "from", "line", ".", "value", "then", "split", "on", "commas", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L860-L867
eventable/vobject
docs/build/lib/vobject/icalendar.py
MultiTextBehavior.encode
def encode(cls, line): """ Backslash escape line.value. """ if not line.encoded: line.value = cls.listSeparator.join(backslashEscape(val) for val in line.value) line.encoded=True
python
def encode(cls, line): """ Backslash escape line.value. """ if not line.encoded: line.value = cls.listSeparator.join(backslashEscape(val) for val in line.value) line.encoded=True
[ "def", "encode", "(", "cls", ",", "line", ")", ":", "if", "not", "line", ".", "encoded", ":", "line", ".", "value", "=", "cls", ".", "listSeparator", ".", "join", "(", "backslashEscape", "(", "val", ")", "for", "val", "in", "line", ".", "value", ")...
Backslash escape line.value.
[ "Backslash", "escape", "line", ".", "value", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L870-L877
eventable/vobject
docs/build/lib/vobject/icalendar.py
VCalendar2_0.generateImplicitParameters
def generateImplicitParameters(cls, obj): """ Create PRODID, VERSION, and VTIMEZONEs if needed. VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist. """ for comp in obj.components(): if comp.behavior is not None: ...
python
def generateImplicitParameters(cls, obj): """ Create PRODID, VERSION, and VTIMEZONEs if needed. VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist. """ for comp in obj.components(): if comp.behavior is not None: ...
[ "def", "generateImplicitParameters", "(", "cls", ",", "obj", ")", ":", "for", "comp", "in", "obj", ".", "components", "(", ")", ":", "if", "comp", ".", "behavior", "is", "not", "None", ":", "comp", ".", "behavior", ".", "generateImplicitParameters", "(", ...
Create PRODID, VERSION, and VTIMEZONEs if needed. VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist.
[ "Create", "PRODID", "VERSION", "and", "VTIMEZONEs", "if", "needed", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L906-L948
eventable/vobject
docs/build/lib/vobject/icalendar.py
VAlarm.generateImplicitParameters
def generateImplicitParameters(obj): """ Create default ACTION and TRIGGER if they're not set. """ try: obj.action except AttributeError: obj.add('action').value = 'AUDIO' try: obj.trigger except AttributeError: obj....
python
def generateImplicitParameters(obj): """ Create default ACTION and TRIGGER if they're not set. """ try: obj.action except AttributeError: obj.add('action').value = 'AUDIO' try: obj.trigger except AttributeError: obj....
[ "def", "generateImplicitParameters", "(", "obj", ")", ":", "try", ":", "obj", ".", "action", "except", "AttributeError", ":", "obj", ".", "add", "(", "'action'", ")", ".", "value", "=", "'AUDIO'", "try", ":", "obj", ".", "trigger", "except", "AttributeErro...
Create default ACTION and TRIGGER if they're not set.
[ "Create", "default", "ACTION", "and", "TRIGGER", "if", "they", "re", "not", "set", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1208-L1219
eventable/vobject
docs/build/lib/vobject/icalendar.py
Duration.transformToNative
def transformToNative(obj): """ Turn obj.value into a datetime.timedelta. """ if obj.isNative: return obj obj.isNative = True obj.value=obj.value if obj.value == '': return obj else: deltalist=stringToDurations(obj.value...
python
def transformToNative(obj): """ Turn obj.value into a datetime.timedelta. """ if obj.isNative: return obj obj.isNative = True obj.value=obj.value if obj.value == '': return obj else: deltalist=stringToDurations(obj.value...
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "return", "obj", "obj", ".", "isNative", "=", "True", "obj", ".", "value", "=", "obj", ".", "value", "if", "obj", ".", "value", "==", "''", ":", "return", "obj", "...
Turn obj.value into a datetime.timedelta.
[ "Turn", "obj", ".", "value", "into", "a", "datetime", ".", "timedelta", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1332-L1349
eventable/vobject
docs/build/lib/vobject/icalendar.py
Duration.transformFromNative
def transformFromNative(obj): """ Replace the datetime.timedelta in obj.value with an RFC2445 string. """ if not obj.isNative: return obj obj.isNative = False obj.value = timedeltaToString(obj.value) return obj
python
def transformFromNative(obj): """ Replace the datetime.timedelta in obj.value with an RFC2445 string. """ if not obj.isNative: return obj obj.isNative = False obj.value = timedeltaToString(obj.value) return obj
[ "def", "transformFromNative", "(", "obj", ")", ":", "if", "not", "obj", ".", "isNative", ":", "return", "obj", "obj", ".", "isNative", "=", "False", "obj", ".", "value", "=", "timedeltaToString", "(", "obj", ".", "value", ")", "return", "obj" ]
Replace the datetime.timedelta in obj.value with an RFC2445 string.
[ "Replace", "the", "datetime", ".", "timedelta", "in", "obj", ".", "value", "with", "an", "RFC2445", "string", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1352-L1360
eventable/vobject
docs/build/lib/vobject/icalendar.py
Trigger.transformToNative
def transformToNative(obj): """ Turn obj.value into a timedelta or datetime. """ if obj.isNative: return obj value = getattr(obj, 'value_param', 'DURATION').upper() if hasattr(obj, 'value_param'): del obj.value_param if obj.value == '': ...
python
def transformToNative(obj): """ Turn obj.value into a timedelta or datetime. """ if obj.isNative: return obj value = getattr(obj, 'value_param', 'DURATION').upper() if hasattr(obj, 'value_param'): del obj.value_param if obj.value == '': ...
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "return", "obj", "value", "=", "getattr", "(", "obj", ",", "'value_param'", ",", "'DURATION'", ")", ".", "upper", "(", ")", "if", "hasattr", "(", "obj", ",", "'value_p...
Turn obj.value into a timedelta or datetime.
[ "Turn", "obj", ".", "value", "into", "a", "timedelta", "or", "datetime", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1374-L1406
eventable/vobject
docs/build/lib/vobject/icalendar.py
PeriodBehavior.transformToNative
def transformToNative(obj): """ Convert comma separated periods into tuples. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': obj.value = [] return obj tzinfo = getTzid(getattr(obj, 'tzid_param', None)) ...
python
def transformToNative(obj): """ Convert comma separated periods into tuples. """ if obj.isNative: return obj obj.isNative = True if obj.value == '': obj.value = [] return obj tzinfo = getTzid(getattr(obj, 'tzid_param', None)) ...
[ "def", "transformToNative", "(", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "return", "obj", "obj", ".", "isNative", "=", "True", "if", "obj", ".", "value", "==", "''", ":", "obj", ".", "value", "=", "[", "]", "return", "obj", "tzinfo", "=...
Convert comma separated periods into tuples.
[ "Convert", "comma", "separated", "periods", "into", "tuples", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1428-L1440
eventable/vobject
docs/build/lib/vobject/icalendar.py
PeriodBehavior.transformFromNative
def transformFromNative(cls, obj): """ Convert the list of tuples in obj.value to strings. """ if obj.isNative: obj.isNative = False transformed = [] for tup in obj.value: transformed.append(periodToString(tup, cls.forceUTC)) ...
python
def transformFromNative(cls, obj): """ Convert the list of tuples in obj.value to strings. """ if obj.isNative: obj.isNative = False transformed = [] for tup in obj.value: transformed.append(periodToString(tup, cls.forceUTC)) ...
[ "def", "transformFromNative", "(", "cls", ",", "obj", ")", ":", "if", "obj", ".", "isNative", ":", "obj", ".", "isNative", "=", "False", "transformed", "=", "[", "]", "for", "tup", "in", "obj", ".", "value", ":", "transformed", ".", "append", "(", "p...
Convert the list of tuples in obj.value to strings.
[ "Convert", "the", "list", "of", "tuples", "in", "obj", ".", "value", "to", "strings", "." ]
train
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1443-L1459