repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_num_contracts
def _get_num_contracts(contracts_list, param_name): """ Return the number of simple/default contracts. Simple contracts are the ones which raise a RuntimeError with message 'Argument `*[argument_name]*` is not valid' """ msg = "Argument `*[argument_name]*` is not valid" return sum( ...
python
def _get_num_contracts(contracts_list, param_name): """ Return the number of simple/default contracts. Simple contracts are the ones which raise a RuntimeError with message 'Argument `*[argument_name]*` is not valid' """ msg = "Argument `*[argument_name]*` is not valid" return sum( ...
[ "def", "_get_num_contracts", "(", "contracts_list", ",", "param_name", ")", ":", "msg", "=", "\"Argument `*[argument_name]*` is not valid\"", "return", "sum", "(", "[", "1", "if", "item", "[", "\"msg\"", "]", "==", "msg", ".", "replace", "(", "\"*[argument_name]*\...
Return the number of simple/default contracts. Simple contracts are the ones which raise a RuntimeError with message 'Argument `*[argument_name]*` is not valid'
[ "Return", "the", "number", "of", "simple", "/", "default", "contracts", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L288-L301
train
Return the number of simple or default contracts.
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_replacement_token
def _get_replacement_token(msg): """Extract replacement token from exception message.""" return ( None if not re.search(r"\*\[[\w|\W]+\]\*", msg) else re.search(r"\*\[[\w|\W]+\]\*", msg).group()[2:-2] )
python
def _get_replacement_token(msg): """Extract replacement token from exception message.""" return ( None if not re.search(r"\*\[[\w|\W]+\]\*", msg) else re.search(r"\*\[[\w|\W]+\]\*", msg).group()[2:-2] )
[ "def", "_get_replacement_token", "(", "msg", ")", ":", "return", "(", "None", "if", "not", "re", ".", "search", "(", "r\"\\*\\[[\\w|\\W]+\\]\\*\"", ",", "msg", ")", "else", "re", ".", "search", "(", "r\"\\*\\[[\\w|\\W]+\\]\\*\"", ",", "msg", ")", ".", "group...
Extract replacement token from exception message.
[ "Extract", "replacement", "token", "from", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L304-L310
train
Extract replacement token from exception message.
pmacosta/pexdoc
pexdoc/pcontracts.py
_parse_new_contract_args
def _parse_new_contract_args(*args, **kwargs): """Parse argument for new_contract() function.""" # No arguments if (not args) and (not kwargs): return [ { "name": "argument_invalid", "msg": "Argument `*[argument_name]*` is not valid", "type...
python
def _parse_new_contract_args(*args, **kwargs): """Parse argument for new_contract() function.""" # No arguments if (not args) and (not kwargs): return [ { "name": "argument_invalid", "msg": "Argument `*[argument_name]*` is not valid", "type...
[ "def", "_parse_new_contract_args", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# No arguments", "if", "(", "not", "args", ")", "and", "(", "not", "kwargs", ")", ":", "return", "[", "{", "\"name\"", ":", "\"argument_invalid\"", ",", "\"msg\"", "...
Parse argument for new_contract() function.
[ "Parse", "argument", "for", "new_contract", "()", "function", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L313-L333
train
Parse argument for new_contract() function.
pmacosta/pexdoc
pexdoc/pcontracts.py
_register_custom_contracts
def _register_custom_contracts(contract_name, contract_exceptions): """Homogenize custom contract exception definition.""" # pylint: disable=W0602,W0603 global _CUSTOM_CONTRACTS # Validate arguments and homogenize contract exceptions if not isinstance(contract_name, str): raise TypeError("Ar...
python
def _register_custom_contracts(contract_name, contract_exceptions): """Homogenize custom contract exception definition.""" # pylint: disable=W0602,W0603 global _CUSTOM_CONTRACTS # Validate arguments and homogenize contract exceptions if not isinstance(contract_name, str): raise TypeError("Ar...
[ "def", "_register_custom_contracts", "(", "contract_name", ",", "contract_exceptions", ")", ":", "# pylint: disable=W0602,W0603", "global", "_CUSTOM_CONTRACTS", "# Validate arguments and homogenize contract exceptions", "if", "not", "isinstance", "(", "contract_name", ",", "str",...
Homogenize custom contract exception definition.
[ "Homogenize", "custom", "contract", "exception", "definition", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L336-L439
train
Register custom contracts.
projectshift/shift-schema
shiftschema/filters/uppercase.py
Uppercase.filter
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context ...
python
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context ...
[ "def", "filter", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "value", "=", "str", "(", "value", ")", "return", "value", ".", "upper", "(", ")" ]
Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context :return: filtered value
[ "Filter", "Performs", "value", "filtering", "and", "returns", "filtered", "result", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/filters/uppercase.py#L11-L22
train
Filter the value of the key - value pair and returns the result.
contains-io/typet
typet/objects.py
_get_type_name
def _get_type_name(type_): # type: (type) -> str """Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence. """ name = repr(type_) if name.startswith("<")...
python
def _get_type_name(type_): # type: (type) -> str """Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence. """ name = repr(type_) if name.startswith("<")...
[ "def", "_get_type_name", "(", "type_", ")", ":", "# type: (type) -> str", "name", "=", "repr", "(", "type_", ")", "if", "name", ".", "startswith", "(", "\"<\"", ")", ":", "name", "=", "getattr", "(", "type_", ",", "\"__qualname__\"", ",", "getattr", "(", ...
Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence.
[ "Return", "a", "displayable", "name", "for", "the", "type", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L46-L60
train
Return a displayable name for the type.
contains-io/typet
typet/objects.py
_get_class_frame_source
def _get_class_frame_source(class_name): # type: (str) -> Optional[str] """Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look fo...
python
def _get_class_frame_source(class_name): # type: (str) -> Optional[str] """Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look fo...
[ "def", "_get_class_frame_source", "(", "class_name", ")", ":", "# type: (str) -> Optional[str]", "for", "frame_info", "in", "inspect", ".", "stack", "(", ")", ":", "try", ":", "with", "open", "(", "frame_info", "[", "1", "]", ")", "as", "fp", ":", "src", "...
Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look for on the stack. Returns: The source code for the requested class if th...
[ "Return", "the", "source", "code", "for", "a", "class", "by", "checking", "the", "frame", "stack", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L63-L107
train
Returns the source code for a class from the stack.
contains-io/typet
typet/objects.py
_is_propertyable
def _is_propertyable( names, # type: List[str] attrs, # type: Dict[str, Any] annotations, # type: Dict[str, type] attr, # Dict[str, Any] ): # type: (...) -> bool """Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names f...
python
def _is_propertyable( names, # type: List[str] attrs, # type: Dict[str, Any] annotations, # type: Dict[str, type] attr, # Dict[str, Any] ): # type: (...) -> bool """Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names f...
[ "def", "_is_propertyable", "(", "names", ",", "# type: List[str]", "attrs", ",", "# type: Dict[str, Any]", "annotations", ",", "# type: Dict[str, type]", "attr", ",", "# Dict[str, Any]", ")", ":", "# type: (...) -> bool", "return", "(", "attr", "in", "annotations", "and...
Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names for the class. attrs: The attribute dict returned by __prepare__. annotations: A mapping of all defined annotations for the class. attr: The attribute to test. Retur...
[ "Determine", "if", "an", "attribute", "can", "be", "replaced", "with", "a", "property", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L110-L134
train
Checks if an attribute can be replaced with a property.
contains-io/typet
typet/objects.py
_create_typed_object_meta
def _create_typed_object_meta(get_fset): # type: (Callable[[str, str, Type[_T]], Callable[[_T], None]]) -> type """Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the ...
python
def _create_typed_object_meta(get_fset): # type: (Callable[[str, str, Type[_T]], Callable[[_T], None]]) -> type """Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the ...
[ "def", "_create_typed_object_meta", "(", "get_fset", ")", ":", "# type: (Callable[[str, str, Type[_T]], Callable[[_T], None]]) -> type", "def", "_get_fget", "(", "attr", ",", "private_attr", ",", "type_", ")", ":", "# type: (str, str, Type[_T]) -> Callable[[], Any]", "\"\"\"Creat...
Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the property data, and a type. This function must an object method that accepts a value. Returns: ...
[ "Create", "a", "metaclass", "for", "typed", "objects", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L137-L256
train
Create a metaclass that reads annotations from a class definition and creates a property getter method for an object.
contains-io/typet
typet/objects.py
_strict_object_meta_fset
def _strict_object_meta_fset(_, private_attr, type_): # type: (str, str, Type[_T]) -> Callable[[_T], None] """Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data re...
python
def _strict_object_meta_fset(_, private_attr, type_): # type: (str, str, Type[_T]) -> Callable[[_T], None] """Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data re...
[ "def", "_strict_object_meta_fset", "(", "_", ",", "private_attr", ",", "type_", ")", ":", "# type: (str, str, Type[_T]) -> Callable[[_T], None]", "def", "_fset", "(", "self", ",", "value", ")", ":", "# type: Any", "# type: (...) -> None", "\"\"\"Set the value on self iff th...
Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data related to the attribute. type_: The annotated type defining what values can be stored in the attrib...
[ "Create", "a", "property", "setter", "method", "for", "the", "attribute", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L259-L299
train
Create a property setter method for the object meta class.
contains-io/typet
typet/objects.py
_object_meta_fset
def _object_meta_fset(_, private_attr, type_): # type: (str, str, Type[_T]) -> Callable[[_T], None] """Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data related t...
python
def _object_meta_fset(_, private_attr, type_): # type: (str, str, Type[_T]) -> Callable[[_T], None] """Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data related t...
[ "def", "_object_meta_fset", "(", "_", ",", "private_attr", ",", "type_", ")", ":", "# type: (str, str, Type[_T]) -> Callable[[_T], None]", "def", "_fset", "(", "self", ",", "value", ")", ":", "# type: Any", "# type: (...) -> None", "\"\"\"Set the value on self and coerce it...
Create a property setter method for the attribute. Args: _: The name of the attribute to set. Unused. private_attr: The name of the attribute that will store any data related to the attribute. type_: The annotated type defining what values can be stored in the attrib...
[ "Create", "a", "property", "setter", "method", "for", "the", "attribute", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L305-L341
train
Create a property setter method for the object.
contains-io/typet
typet/objects.py
_AnnotatedObjectComparisonMixin._tp__get_typed_properties
def _tp__get_typed_properties(self): """Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta. """ try: return tuple(ge...
python
def _tp__get_typed_properties(self): """Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta. """ try: return tuple(ge...
[ "def", "_tp__get_typed_properties", "(", "self", ")", ":", "try", ":", "return", "tuple", "(", "getattr", "(", "self", ",", "p", ")", "for", "p", "in", "self", ".", "_tp__typed_properties", ")", "except", "AttributeError", ":", "raise", "NotImplementedError" ]
Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta.
[ "Return", "a", "tuple", "of", "typed", "attrs", "that", "can", "be", "used", "for", "comparisons", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L398-L408
train
Return a tuple of typed attrs that can be used for comparisons.
dmonroy/chilero
chilero/web/__init__.py
run
def run(cls, routes, *args, **kwargs): # pragma: no cover """ Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None """ app = init(cls, routes, *args, **kwargs) ...
python
def run(cls, routes, *args, **kwargs): # pragma: no cover """ Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None """ app = init(cls, routes, *args, **kwargs) ...
[ "def", "run", "(", "cls", ",", "routes", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover", "app", "=", "init", "(", "cls", ",", "routes", ",", "*", "args", ",", "*", "*", "kwargs", ")", "HOST", "=", "os", ".", "getenv", ...
Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None
[ "Run", "a", "web", "application", "." ]
8f1118a60cb7eab3f9ad31cb8a14b30bc102893d
https://github.com/dmonroy/chilero/blob/8f1118a60cb7eab3f9ad31cb8a14b30bc102893d/chilero/web/__init__.py#L25-L41
train
Run a web application.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/entomology.py
Seasonality.monthlyValues
def monthlyValues(self): """ Description of seasonality from monthly values. Multiple smoothing methods are possible (see smoothing attribute). List should contain twelve entries: January to December. :rtype: list https://github.com/SwissTPH/openmalaria/wiki/GeneratedSch...
python
def monthlyValues(self): """ Description of seasonality from monthly values. Multiple smoothing methods are possible (see smoothing attribute). List should contain twelve entries: January to December. :rtype: list https://github.com/SwissTPH/openmalaria/wiki/GeneratedSch...
[ "def", "monthlyValues", "(", "self", ")", ":", "monthly_values", "=", "[", "]", "for", "value", "in", "self", ".", "et", ".", "find", "(", "\"monthlyValues\"", ")", ".", "findall", "(", "\"value\"", ")", ":", "monthly_values", ".", "append", "(", "float"...
Description of seasonality from monthly values. Multiple smoothing methods are possible (see smoothing attribute). List should contain twelve entries: January to December. :rtype: list https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#list-of-monthly-values
[ "Description", "of", "seasonality", "from", "monthly", "values", ".", "Multiple", "smoothing", "methods", "are", "possible", "(", "see", "smoothing", "attribute", ")", ".", "List", "should", "contain", "twelve", "entries", ":", "January", "to", "December", ".", ...
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/entomology.py#L64-L76
train
Returns a list of monthly values.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/entomology.py
Vectors.add
def add(self, vector, InterventionAnophelesParams=None): """ Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml ...
python
def add(self, vector, InterventionAnophelesParams=None): """ Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml ...
[ "def", "add", "(", "self", ",", "vector", ",", "InterventionAnophelesParams", "=", "None", ")", ":", "# TODO", "# 1. If there are GVI interventions, for every GVI, add anophelesParams section.", "# (gvi_anophelesParams field in AnophelesSnippets models)", "# 2. If there are ITN interve...
Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml
[ "Add", "a", "vector", "to", "entomology", "section", ".", "vector", "is", "either", "ElementTree", "or", "xml", "snippet" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/entomology.py#L197-L222
train
Add a vector to an entomology section.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/entomology.py
Vectors.vectors
def vectors(self): """ :rtype: dict """ vectors = {} for anopheles in self.et.findall("anopheles"): vectors[anopheles.attrib["mosquito"]] = Vector(anopheles) return vectors
python
def vectors(self): """ :rtype: dict """ vectors = {} for anopheles in self.et.findall("anopheles"): vectors[anopheles.attrib["mosquito"]] = Vector(anopheles) return vectors
[ "def", "vectors", "(", "self", ")", ":", "vectors", "=", "{", "}", "for", "anopheles", "in", "self", ".", "et", ".", "findall", "(", "\"anopheles\"", ")", ":", "vectors", "[", "anopheles", ".", "attrib", "[", "\"mosquito\"", "]", "]", "=", "Vector", ...
:rtype: dict
[ ":", "rtype", ":", "dict" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/entomology.py#L225-L232
train
Return a dictionary of all the anopheles in the log.
pmacosta/pexdoc
pexdoc/exdoc.py
_format_msg
def _format_msg(text, width, indent=0, prefix=""): r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed """ text = repr(text).replace("`", "\\`").replace("\\n", " ``\\n`` ") sindent = " " * indent if not prefix else prefix wrap...
python
def _format_msg(text, width, indent=0, prefix=""): r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed """ text = repr(text).replace("`", "\\`").replace("\\n", " ``\\n`` ") sindent = " " * indent if not prefix else prefix wrap...
[ "def", "_format_msg", "(", "text", ",", "width", ",", "indent", "=", "0", ",", "prefix", "=", "\"\"", ")", ":", "text", "=", "repr", "(", "text", ")", ".", "replace", "(", "\"`\"", ",", "\"\\\\`\"", ")", ".", "replace", "(", "\"\\\\n\"", ",", "\" `...
r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed
[ "r", "Format", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L44-L55
train
r Format exception message.
pmacosta/pexdoc
pexdoc/exdoc.py
_validate_fname
def _validate_fname(fname, arg_name): """Validate that a string is a valid file name.""" if fname is not None: msg = "Argument `{0}` is not valid".format(arg_name) if (not isinstance(fname, str)) or (isinstance(fname, str) and ("\0" in fname)): raise RuntimeError(msg) try: ...
python
def _validate_fname(fname, arg_name): """Validate that a string is a valid file name.""" if fname is not None: msg = "Argument `{0}` is not valid".format(arg_name) if (not isinstance(fname, str)) or (isinstance(fname, str) and ("\0" in fname)): raise RuntimeError(msg) try: ...
[ "def", "_validate_fname", "(", "fname", ",", "arg_name", ")", ":", "if", "fname", "is", "not", "None", ":", "msg", "=", "\"Argument `{0}` is not valid\"", ".", "format", "(", "arg_name", ")", "if", "(", "not", "isinstance", "(", "fname", ",", "str", ")", ...
Validate that a string is a valid file name.
[ "Validate", "that", "a", "string", "is", "a", "valid", "file", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L58-L68
train
Validate that a string is a valid file name.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._build_ex_tree
def _build_ex_tree(self): """Construct exception tree from trace.""" # Load exception data into tree structure sep = self._exh_obj.callables_separator data = self._exh_obj.exceptions_db if not data: raise RuntimeError("Exceptions database is empty") # Add root...
python
def _build_ex_tree(self): """Construct exception tree from trace.""" # Load exception data into tree structure sep = self._exh_obj.callables_separator data = self._exh_obj.exceptions_db if not data: raise RuntimeError("Exceptions database is empty") # Add root...
[ "def", "_build_ex_tree", "(", "self", ")", ":", "# Load exception data into tree structure", "sep", "=", "self", ".", "_exh_obj", ".", "callables_separator", "data", "=", "self", ".", "_exh_obj", ".", "exceptions_db", "if", "not", "data", ":", "raise", "RuntimeErr...
Construct exception tree from trace.
[ "Construct", "exception", "tree", "from", "trace", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L324-L354
train
Construct exception tree from trace.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._build_module_db
def _build_module_db(self): """ Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module """ tdic...
python
def _build_module_db(self): """ Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module """ tdic...
[ "def", "_build_module_db", "(", "self", ")", ":", "tdict", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "[", "]", ")", "for", "callable_name", ",", "callable_dict", "in", "self", ".", "_exh_obj", ".", "callables_db", ".", "items", "(", ")", ...
Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module
[ "Build", "database", "of", "module", "callables", "sorted", "by", "line", "number", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L356-L376
train
Builds the database of module callables sorted by line number.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._process_exlist
def _process_exlist(self, exc, raised): """Remove raised info from exception message and create separate list for it.""" if (not raised) or (raised and exc.endswith("*")): return exc[:-1] if exc.endswith("*") else exc return None
python
def _process_exlist(self, exc, raised): """Remove raised info from exception message and create separate list for it.""" if (not raised) or (raised and exc.endswith("*")): return exc[:-1] if exc.endswith("*") else exc return None
[ "def", "_process_exlist", "(", "self", ",", "exc", ",", "raised", ")", ":", "if", "(", "not", "raised", ")", "or", "(", "raised", "and", "exc", ".", "endswith", "(", "\"*\"", ")", ")", ":", "return", "exc", "[", ":", "-", "1", "]", "if", "exc", ...
Remove raised info from exception message and create separate list for it.
[ "Remove", "raised", "info", "from", "exception", "message", "and", "create", "separate", "list", "for", "it", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L391-L395
train
Remove raised info from exception message and create separate list for it.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._set_depth
def _set_depth(self, depth): """Depth setter.""" if depth and ( (not isinstance(depth, int)) or (isinstance(depth, int) and (depth < 0)) ): raise RuntimeError("Argument `depth` is not valid") self._depth = depth
python
def _set_depth(self, depth): """Depth setter.""" if depth and ( (not isinstance(depth, int)) or (isinstance(depth, int) and (depth < 0)) ): raise RuntimeError("Argument `depth` is not valid") self._depth = depth
[ "def", "_set_depth", "(", "self", ",", "depth", ")", ":", "if", "depth", "and", "(", "(", "not", "isinstance", "(", "depth", ",", "int", ")", ")", "or", "(", "isinstance", "(", "depth", ",", "int", ")", "and", "(", "depth", "<", "0", ")", ")", ...
Depth setter.
[ "Depth", "setter", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L397-L403
train
Depth setter.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._set_exclude
def _set_exclude(self, exclude): """Exclude setter.""" if exclude and ( (not isinstance(exclude, list)) or ( isinstance(exclude, list) and any([not isinstance(item, str) for item in exclude]) ) ): raise RuntimeError(...
python
def _set_exclude(self, exclude): """Exclude setter.""" if exclude and ( (not isinstance(exclude, list)) or ( isinstance(exclude, list) and any([not isinstance(item, str) for item in exclude]) ) ): raise RuntimeError(...
[ "def", "_set_exclude", "(", "self", ",", "exclude", ")", ":", "if", "exclude", "and", "(", "(", "not", "isinstance", "(", "exclude", ",", "list", ")", ")", "or", "(", "isinstance", "(", "exclude", ",", "list", ")", "and", "any", "(", "[", "not", "i...
Exclude setter.
[ "Exclude", "setter", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L405-L415
train
Exclude setter.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc.get_sphinx_autodoc
def get_sphinx_autodoc( self, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to inclu...
python
def get_sphinx_autodoc( self, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to inclu...
[ "def", "get_sphinx_autodoc", "(", "self", ",", "depth", "=", "None", ",", "exclude", "=", "None", ",", "width", "=", "72", ",", "error", "=", "False", ",", "raised", "=", "False", ",", "no_comment", "=", "False", ",", ")", ":", "# This code is cog-specif...
r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to include in the exceptions list (overrides default **depth** argument; see :py:attr:`pexdoc.ExDoc.depth`). If None exceptions ...
[ "r", "Return", "exception", "list", "in", "reStructuredText", "_", "auto", "-", "determining", "callable", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L417-L503
train
r Return a reStructuredText_Auto - doc string for the given callable name.
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc.get_sphinx_doc
def get_sphinx_doc( self, name, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return an exception list marked up in `reStructuredText`_. :param name: Name of the callable (method, func...
python
def get_sphinx_doc( self, name, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return an exception list marked up in `reStructuredText`_. :param name: Name of the callable (method, func...
[ "def", "get_sphinx_doc", "(", "self", ",", "name", ",", "depth", "=", "None", ",", "exclude", "=", "None", ",", "width", "=", "72", ",", "error", "=", "False", ",", "raised", "=", "False", ",", "no_comment", "=", "False", ",", ")", ":", "# pylint: di...
r""" Return an exception list marked up in `reStructuredText`_. :param name: Name of the callable (method, function or class property) to generate exceptions documentation for :type name: string :param depth: Hierarchy levels to include in the exceptions ...
[ "r", "Return", "an", "exception", "list", "marked", "up", "in", "reStructuredText", "_", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L505-L757
train
r Generate a sphinx - formatted version of the exception list for a given module and callable.
a1ezzz/wasp-general
wasp_general/types/bytearray.py
WFixedSizeByteArray.resize
def resize(self, size): """ Grow this array to specified length. This array can't be shrinked :param size: new length :return: None """ if size < len(self): raise ValueError("Value is out of bound. Array can't be shrinked") current_size = self.__size for i in range(size - current_size): self.__arra...
python
def resize(self, size): """ Grow this array to specified length. This array can't be shrinked :param size: new length :return: None """ if size < len(self): raise ValueError("Value is out of bound. Array can't be shrinked") current_size = self.__size for i in range(size - current_size): self.__arra...
[ "def", "resize", "(", "self", ",", "size", ")", ":", "if", "size", "<", "len", "(", "self", ")", ":", "raise", "ValueError", "(", "\"Value is out of bound. Array can't be shrinked\"", ")", "current_size", "=", "self", ".", "__size", "for", "i", "in", "range"...
Grow this array to specified length. This array can't be shrinked :param size: new length :return: None
[ "Grow", "this", "array", "to", "specified", "length", ".", "This", "array", "can", "t", "be", "shrinked" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/types/bytearray.py#L83-L94
train
Grow this array to specified length. This array can t be shrinked raise ValueError if the size is out of bound.
a1ezzz/wasp-general
wasp_general/types/bytearray.py
WFixedSizeByteArray.swipe
def swipe(self): """ Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray """ result = WFixedSizeByteArray(len(self)) for i in range(len...
python
def swipe(self): """ Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray """ result = WFixedSizeByteArray(len(self)) for i in range(len...
[ "def", "swipe", "(", "self", ")", ":", "result", "=", "WFixedSizeByteArray", "(", "len", "(", "self", ")", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "result", "[", "len", "(", "self", ")", "-", "i", "-", "1", "]", ...
Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray
[ "Mirror", "current", "array", "value", "in", "reverse", ".", "Bytes", "that", "had", "greater", "index", "will", "have", "lesser", "index", "and", "vice", "-", "versa", ".", "This", "method", "doesn", "t", "change", "this", "array", ".", "It", "creates", ...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/types/bytearray.py#L140-L149
train
Mirror current array value in reverse. Bytes that had greater index will have lesser index and and vice - versa will have lesser index and and vice - versa.
a1ezzz/wasp-general
wasp_general/mime.py
mime_type
def mime_type(filename): """ Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str """ # TODO: write lock-free mim...
python
def mime_type(filename): """ Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str """ # TODO: write lock-free mim...
[ "def", "mime_type", "(", "filename", ")", ":", "# TODO: write lock-free mime_type function", "try", ":", "__mime_lock", ".", "acquire", "(", ")", "extension", "=", "filename", ".", "split", "(", "\".\"", ")", "extension", "=", "extension", "[", "len", "(", "ex...
Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str
[ "Guess", "mime", "type", "for", "the", "given", "file", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/mime.py#L36-L65
train
Guess mime type for the given file name.
Loudr/pale
pale/arguments/base.py
BaseArgument._validate_type
def _validate_type(self, item, name): """Validate the item against `allowed_types`.""" if item is None: # don't validate None items, since they'll be caught by the portion # of the validator responsible for handling `required`ness return if not isinstance(ite...
python
def _validate_type(self, item, name): """Validate the item against `allowed_types`.""" if item is None: # don't validate None items, since they'll be caught by the portion # of the validator responsible for handling `required`ness return if not isinstance(ite...
[ "def", "_validate_type", "(", "self", ",", "item", ",", "name", ")", ":", "if", "item", "is", "None", ":", "# don't validate None items, since they'll be caught by the portion", "# of the validator responsible for handling `required`ness", "return", "if", "not", "isinstance",...
Validate the item against `allowed_types`.
[ "Validate", "the", "item", "against", "allowed_types", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L59-L70
train
Validate the item against allowed_types.
Loudr/pale
pale/arguments/base.py
BaseArgument._validate_required
def _validate_required(self, item, name): """Validate that the item is present if it's required.""" if self.required is True and item is None: raise ArgumentError(name, "This argument is required.")
python
def _validate_required(self, item, name): """Validate that the item is present if it's required.""" if self.required is True and item is None: raise ArgumentError(name, "This argument is required.")
[ "def", "_validate_required", "(", "self", ",", "item", ",", "name", ")", ":", "if", "self", ".", "required", "is", "True", "and", "item", "is", "None", ":", "raise", "ArgumentError", "(", "name", ",", "\"This argument is required.\"", ")" ]
Validate that the item is present if it's required.
[ "Validate", "that", "the", "item", "is", "present", "if", "it", "s", "required", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L73-L76
train
Validate that the item is present if it s required.
Loudr/pale
pale/arguments/base.py
BaseArgument.doc_dict
def doc_dict(self): """Returns the documentation dictionary for this argument.""" doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): ...
python
def doc_dict(self): """Returns the documentation dictionary for this argument.""" doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): ...
[ "def", "doc_dict", "(", "self", ")", ":", "doc", "=", "{", "'type'", ":", "self", ".", "__class__", ".", "__name__", ",", "'description'", ":", "self", ".", "description", ",", "'default'", ":", "self", ".", "default", ",", "'required'", ":", "self", "...
Returns the documentation dictionary for this argument.
[ "Returns", "the", "documentation", "dictionary", "for", "this", "argument", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L79-L89
train
Returns the documentation dictionary for this argument.
Loudr/pale
pale/arguments/base.py
ListArgument.validate_items
def validate_items(self, input_list): """Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.""" output_list = [] for item in input_list: valid = self.list_item_type.validate(item, s...
python
def validate_items(self, input_list): """Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.""" output_list = [] for item in input_list: valid = self.list_item_type.validate(item, s...
[ "def", "validate_items", "(", "self", ",", "input_list", ")", ":", "output_list", "=", "[", "]", "for", "item", "in", "input_list", ":", "valid", "=", "self", ".", "list_item_type", ".", "validate", "(", "item", ",", "self", ".", "item_name", ")", "outpu...
Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.
[ "Validates", "that", "items", "in", "the", "list", "are", "of", "the", "type", "specified", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L114-L128
train
Validates that items in the list are of the type specified. Returns the input list if it s valid raises an ArgumentError if it s not valid.
F483/apigen
apigen/apigen.py
Definition.startserver
def startserver(self, hostname="localhost", port=8080, daemon=False, handle_sigint=True): """Start json-rpc service.""" if daemon: print("Sorry daemon server not supported just yet.") # TODO start as daemon similar to bitcoind else: print("...
python
def startserver(self, hostname="localhost", port=8080, daemon=False, handle_sigint=True): """Start json-rpc service.""" if daemon: print("Sorry daemon server not supported just yet.") # TODO start as daemon similar to bitcoind else: print("...
[ "def", "startserver", "(", "self", ",", "hostname", "=", "\"localhost\"", ",", "port", "=", "8080", ",", "daemon", "=", "False", ",", "handle_sigint", "=", "True", ")", ":", "if", "daemon", ":", "print", "(", "\"Sorry daemon server not supported just yet.\"", ...
Start json-rpc service.
[ "Start", "json", "-", "rpc", "service", "." ]
f05ce1509030764721cc3393410fa12b609e88f2
https://github.com/F483/apigen/blob/f05ce1509030764721cc3393410fa12b609e88f2/apigen/apigen.py#L118-L138
train
Start json - rpc service.
OpenGov/og-python-utils
ogutils/collections/operators.py
apply_dict_default
def apply_dict_default(dictionary, arg, default): ''' Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object apply_dict_default({}, 'test', list) # => {'test': []} apply_dict_default({'test': 'ok'}, 'test', list) # => {'test': 'ok'} ''' if ...
python
def apply_dict_default(dictionary, arg, default): ''' Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object apply_dict_default({}, 'test', list) # => {'test': []} apply_dict_default({'test': 'ok'}, 'test', list) # => {'test': 'ok'} ''' if ...
[ "def", "apply_dict_default", "(", "dictionary", ",", "arg", ",", "default", ")", ":", "if", "arg", "not", "in", "dictionary", ":", "if", "hasattr", "(", "default", ",", "'__call__'", ")", ":", "# Don't try/catch because the method could raise a TypeError and we'd hide...
Used to avoid generating a defaultdict object, or assigning defaults to a dict-like object apply_dict_default({}, 'test', list) # => {'test': []} apply_dict_default({'test': 'ok'}, 'test', list) # => {'test': 'ok'}
[ "Used", "to", "avoid", "generating", "a", "defaultdict", "object", "or", "assigning", "defaults", "to", "a", "dict", "-", "like", "object", "apply_dict_default", "(", "{}", "test", "list", ")", "#", "=", ">", "{", "test", ":", "[]", "}", "apply_dict_defaul...
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/operators.py#L3-L18
train
Applies a default value to a dictionary.
dfujim/bdata
bdata/bdata.py
bdata._get_area_data
def _get_area_data(self): """Get histogram list based on area type. List pattern: [type1_hel+,type2_hel+,type1_hel-,type2_hel-] where type1/2 = F/B or R/L in that order. """ if self.mode == '1n': data = [self.hist['NBMF+'].data,\ self.his...
python
def _get_area_data(self): """Get histogram list based on area type. List pattern: [type1_hel+,type2_hel+,type1_hel-,type2_hel-] where type1/2 = F/B or R/L in that order. """ if self.mode == '1n': data = [self.hist['NBMF+'].data,\ self.his...
[ "def", "_get_area_data", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "'1n'", ":", "data", "=", "[", "self", ".", "hist", "[", "'NBMF+'", "]", ".", "data", ",", "self", ".", "hist", "[", "'NBMF-'", "]", ".", "data", ",", "self", ".", ...
Get histogram list based on area type. List pattern: [type1_hel+,type2_hel+,type1_hel-,type2_hel-] where type1/2 = F/B or R/L in that order.
[ "Get", "histogram", "list", "based", "on", "area", "type", ".", "List", "pattern", ":", "[", "type1_hel", "+", "type2_hel", "+", "type1_hel", "-", "type2_hel", "-", "]", "where", "type1", "/", "2", "=", "F", "/", "B", "or", "R", "/", "L", "in", "th...
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L509-L542
train
Get histogram list based on area type.
dfujim/bdata
bdata/bdata.py
bdata._get_asym_hel
def _get_asym_hel(self,d): """ Find the asymmetry of each helicity. """ # get data 1+ 2+ 1- 2- d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs denom1 = d0+d1; denom2 = d2+d3 # check for div by zero denom1[den...
python
def _get_asym_hel(self,d): """ Find the asymmetry of each helicity. """ # get data 1+ 2+ 1- 2- d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs denom1 = d0+d1; denom2 = d2+d3 # check for div by zero denom1[den...
[ "def", "_get_asym_hel", "(", "self", ",", "d", ")", ":", "# get data 1+ 2+ 1- 2-", "d0", "=", "d", "[", "0", "]", "d1", "=", "d", "[", "2", "]", "d2", "=", "d", "[", "1", "]", "d3", "=", "d", "[", "3", "]", "# pre-calcs", "denom1", "=", "d0", ...
Find the asymmetry of each helicity.
[ "Find", "the", "asymmetry", "of", "each", "helicity", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L545-L577
train
Get the asymmetry of each helicity.
dfujim/bdata
bdata/bdata.py
bdata._get_asym_comb
def _get_asym_comb(self,d): """ Find the combined asymmetry for slr runs. Elegant 4-counter method. """ # get data d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs r_denom = d0*d3 r_denom[r_denom==0] = np.nan r = np.sqrt((d1...
python
def _get_asym_comb(self,d): """ Find the combined asymmetry for slr runs. Elegant 4-counter method. """ # get data d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs r_denom = d0*d3 r_denom[r_denom==0] = np.nan r = np.sqrt((d1...
[ "def", "_get_asym_comb", "(", "self", ",", "d", ")", ":", "# get data", "d0", "=", "d", "[", "0", "]", "d1", "=", "d", "[", "2", "]", "d2", "=", "d", "[", "1", "]", "d3", "=", "d", "[", "3", "]", "# pre-calcs", "r_denom", "=", "d0", "*", "d...
Find the combined asymmetry for slr runs. Elegant 4-counter method.
[ "Find", "the", "combined", "asymmetry", "for", "slr", "runs", ".", "Elegant", "4", "-", "counter", "method", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L580-L610
train
Find the combined asymmetry for slr runs. Elegant 4 - counter method.
dfujim/bdata
bdata/bdata.py
bdata._get_asym_alpha
def _get_asym_alpha(self,a,b): """ Find alpha diffusion ratios from cryo oven with alpha detectors. a: list of alpha detector histograms (each helicity) b: list of beta detector histograms (each helicity) """ # just use AL0 try: ...
python
def _get_asym_alpha(self,a,b): """ Find alpha diffusion ratios from cryo oven with alpha detectors. a: list of alpha detector histograms (each helicity) b: list of beta detector histograms (each helicity) """ # just use AL0 try: ...
[ "def", "_get_asym_alpha", "(", "self", ",", "a", ",", "b", ")", ":", "# just use AL0", "try", ":", "a", "=", "a", "[", "2", ":", "4", "]", "except", "IndexError", ":", "a", "=", "a", "[", ":", "2", "]", "# sum counts in alpha detectors", "asum", "="...
Find alpha diffusion ratios from cryo oven with alpha detectors. a: list of alpha detector histograms (each helicity) b: list of beta detector histograms (each helicity)
[ "Find", "alpha", "diffusion", "ratios", "from", "cryo", "oven", "with", "alpha", "detectors", ".", "a", ":", "list", "of", "alpha", "detector", "histograms", "(", "each", "helicity", ")", "b", ":", "list", "of", "beta", "detector", "histograms", "(", "each...
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L613-L642
train
Find asymmetry and error ratios from cryo oven with alpha detectors.
dfujim/bdata
bdata/bdata.py
bdata._get_1f_sum_scans
def _get_1f_sum_scans(self,d,freq): """ Sum counts in each frequency bin over 1f scans. """ # combine scans: values with same frequency unique_freq = np.unique(freq) sum_scans = [[] for i in range(len(d))] for f in unique_freq: ...
python
def _get_1f_sum_scans(self,d,freq): """ Sum counts in each frequency bin over 1f scans. """ # combine scans: values with same frequency unique_freq = np.unique(freq) sum_scans = [[] for i in range(len(d))] for f in unique_freq: ...
[ "def", "_get_1f_sum_scans", "(", "self", ",", "d", ",", "freq", ")", ":", "# combine scans: values with same frequency ", "unique_freq", "=", "np", ".", "unique", "(", "freq", ")", "sum_scans", "=", "[", "[", "]", "for", "i", "in", "range", "(", "len", "("...
Sum counts in each frequency bin over 1f scans.
[ "Sum", "counts", "in", "each", "frequency", "bin", "over", "1f", "scans", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L672-L687
train
Get 1f sum counts over 1f scans.
dfujim/bdata
bdata/bdata.py
bdata._get_2e_asym
def _get_2e_asym(self): """ Get asymmetries for 2e random-frequency scan. Based on bnmr_2e.cpp by rmlm (Oct 4, 2017). """ # get needed PPG parameters for splitting 1D histos into 2D histos try: # get frequency vector freq ...
python
def _get_2e_asym(self): """ Get asymmetries for 2e random-frequency scan. Based on bnmr_2e.cpp by rmlm (Oct 4, 2017). """ # get needed PPG parameters for splitting 1D histos into 2D histos try: # get frequency vector freq ...
[ "def", "_get_2e_asym", "(", "self", ")", ":", "# get needed PPG parameters for splitting 1D histos into 2D histos", "try", ":", "# get frequency vector", "freq", "=", "np", ".", "arange", "(", "self", ".", "ppg", "[", "'freq_start'", "]", ".", "mean", ",", "self", ...
Get asymmetries for 2e random-frequency scan. Based on bnmr_2e.cpp by rmlm (Oct 4, 2017).
[ "Get", "asymmetries", "for", "2e", "random", "-", "frequency", "scan", ".", "Based", "on", "bnmr_2e", ".", "cpp", "by", "rmlm", "(", "Oct", "4", "2017", ")", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L690-L827
train
Get asymmetries for 2e random - frequency scan.
dfujim/bdata
bdata/bdata.py
bdata._rebin
def _rebin(self,xdx,rebin): """ Rebin array x with weights 1/dx**2 by factor rebin. Inputs: xdx = [x,dx] rebin = int Returns [x,dx] after rebinning. """ x = xdx[0] dx = xdx[1] rebin = int(rebin) ...
python
def _rebin(self,xdx,rebin): """ Rebin array x with weights 1/dx**2 by factor rebin. Inputs: xdx = [x,dx] rebin = int Returns [x,dx] after rebinning. """ x = xdx[0] dx = xdx[1] rebin = int(rebin) ...
[ "def", "_rebin", "(", "self", ",", "xdx", ",", "rebin", ")", ":", "x", "=", "xdx", "[", "0", "]", "dx", "=", "xdx", "[", "1", "]", "rebin", "=", "int", "(", "rebin", ")", "# easy end condition", "if", "rebin", "<=", "1", ":", "return", "(", "x"...
Rebin array x with weights 1/dx**2 by factor rebin. Inputs: xdx = [x,dx] rebin = int Returns [x,dx] after rebinning.
[ "Rebin", "array", "x", "with", "weights", "1", "/", "dx", "**", "2", "by", "factor", "rebin", ".", "Inputs", ":", "xdx", "=", "[", "x", "dx", "]", "rebin", "=", "int", "Returns", "[", "x", "dx", "]", "after", "rebinning", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L830-L867
train
Rebin array x with weights 1 / dx**2 by factor rebin.
dfujim/bdata
bdata/bdata.py
bdata.asym
def asym(self,option="",omit="",rebin=1,hist_select=''): """Calculate and return the asymmetry for various run types. usage: asym(option="",omit="",rebin=1,hist_select='') Inputs: option: see below for details omit: 1f bins to o...
python
def asym(self,option="",omit="",rebin=1,hist_select=''): """Calculate and return the asymmetry for various run types. usage: asym(option="",omit="",rebin=1,hist_select='') Inputs: option: see below for details omit: 1f bins to o...
[ "def", "asym", "(", "self", ",", "option", "=", "\"\"", ",", "omit", "=", "\"\"", ",", "rebin", "=", "1", ",", "hist_select", "=", "''", ")", ":", "# check rebin factor", "if", "type", "(", "rebin", ")", "not", "in", "(", "int", ",", "np", ".", "...
Calculate and return the asymmetry for various run types. usage: asym(option="",omit="",rebin=1,hist_select='') Inputs: option: see below for details omit: 1f bins to omit if space seperated string in options ...
[ "Calculate", "and", "return", "the", "asymmetry", "for", "various", "run", "types", ".", "usage", ":", "asym", "(", "option", "=", "omit", "=", "rebin", "=", "1", "hist_select", "=", ")", "Inputs", ":", "option", ":", "see", "below", "for", "details", ...
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L896-L1294
train
This function calculates the asymmetry of a single object in a single file.
dfujim/bdata
bdata/bdata.py
bdata.beam_kev
def beam_kev(self,get_error=False): """ Get the beam energy in kev, based on typical biases: itw (or ite bias) - bias15 - platform bias if get_error: fetch error in value, rather than value """ # get epics pointer epics =...
python
def beam_kev(self,get_error=False): """ Get the beam energy in kev, based on typical biases: itw (or ite bias) - bias15 - platform bias if get_error: fetch error in value, rather than value """ # get epics pointer epics =...
[ "def", "beam_kev", "(", "self", ",", "get_error", "=", "False", ")", ":", "# get epics pointer", "epics", "=", "self", ".", "epics", "# fetch stds", "if", "get_error", ":", "attr", "=", "'std'", "else", ":", "attr", "=", "'mean'", "# get inital beam energy in ...
Get the beam energy in kev, based on typical biases: itw (or ite bias) - bias15 - platform bias if get_error: fetch error in value, rather than value
[ "Get", "the", "beam", "energy", "in", "kev", "based", "on", "typical", "biases", ":", "itw", "(", "or", "ite", "bias", ")", "-", "bias15", "-", "platform", "bias", "if", "get_error", ":", "fetch", "error", "in", "value", "rather", "than", "value" ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L1297-L1331
train
Get the beam energy in kev based on typical biases itw or ite bias.
dfujim/bdata
bdata/bdata.py
bdata.get_pulse_s
def get_pulse_s(self): """Get pulse duration in seconds, for pulsed measurements.""" try: dwelltime = self.ppg.dwelltime.mean beam_on = self.ppg.beam_on.mean except AttributeError: raise AttributeError("Missing logged ppg parameter: dwelltime "+\ ...
python
def get_pulse_s(self): """Get pulse duration in seconds, for pulsed measurements.""" try: dwelltime = self.ppg.dwelltime.mean beam_on = self.ppg.beam_on.mean except AttributeError: raise AttributeError("Missing logged ppg parameter: dwelltime "+\ ...
[ "def", "get_pulse_s", "(", "self", ")", ":", "try", ":", "dwelltime", "=", "self", ".", "ppg", ".", "dwelltime", ".", "mean", "beam_on", "=", "self", ".", "ppg", ".", "beam_on", ".", "mean", "except", "AttributeError", ":", "raise", "AttributeError", "("...
Get pulse duration in seconds, for pulsed measurements.
[ "Get", "pulse", "duration", "in", "seconds", "for", "pulsed", "measurements", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L1334-L1343
train
Get pulse duration in seconds for pulsed measurements.
OpenGov/og-python-utils
ogutils/text/regex.py
chain_sub_regexes
def chain_sub_regexes(phrase, *regex_sub_pairs): ''' Allow for a series of regex substitutions to occur chain_sub_regexes('test ok', (' ', '_'), ('k$', 'oo')) # => 'test_ooo' ''' for regex, substitution in regex_sub_pairs: if isinstance(regex, basestring): regex = r...
python
def chain_sub_regexes(phrase, *regex_sub_pairs): ''' Allow for a series of regex substitutions to occur chain_sub_regexes('test ok', (' ', '_'), ('k$', 'oo')) # => 'test_ooo' ''' for regex, substitution in regex_sub_pairs: if isinstance(regex, basestring): regex = r...
[ "def", "chain_sub_regexes", "(", "phrase", ",", "*", "regex_sub_pairs", ")", ":", "for", "regex", ",", "substitution", "in", "regex_sub_pairs", ":", "if", "isinstance", "(", "regex", ",", "basestring", ")", ":", "regex", "=", "re", ".", "compile", "(", "re...
Allow for a series of regex substitutions to occur chain_sub_regexes('test ok', (' ', '_'), ('k$', 'oo')) # => 'test_ooo'
[ "Allow", "for", "a", "series", "of", "regex", "substitutions", "to", "occur", "chain_sub_regexes", "(", "test", "ok", "(", "_", ")", "(", "k$", "oo", "))", "#", "=", ">", "test_ooo" ]
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/text/regex.py#L3-L14
train
Given a phrase and a list of regex substitutions return a new phrase.
Loudr/pale
pale/__init__.py
extract_endpoints
def extract_endpoints(api_module): """Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator. """ if not hasattr(api_module, 'endpoints'): raise ValueError(("pale.ex...
python
def extract_endpoints(api_module): """Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator. """ if not hasattr(api_module, 'endpoints'): raise ValueError(("pale.ex...
[ "def", "extract_endpoints", "(", "api_module", ")", ":", "if", "not", "hasattr", "(", "api_module", ",", "'endpoints'", ")", ":", "raise", "ValueError", "(", "(", "\"pale.extract_endpoints expected the passed in \"", "\"api_module to have an `endpoints` attribute, but it didn...
Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator.
[ "Return", "the", "endpoints", "from", "an", "API", "implementation", "module", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/__init__.py#L44-L74
train
Return the endpoints from an API implementation module.
Loudr/pale
pale/__init__.py
extract_resources
def extract_resources(api_module): """Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production. """ endpoints = extract_endpoints(api_module) resource_classes = [ e._returns.__cla...
python
def extract_resources(api_module): """Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production. """ endpoints = extract_endpoints(api_module) resource_classes = [ e._returns.__cla...
[ "def", "extract_resources", "(", "api_module", ")", ":", "endpoints", "=", "extract_endpoints", "(", "api_module", ")", "resource_classes", "=", "[", "e", ".", "_returns", ".", "__class__", "for", "e", "in", "endpoints", "]", "return", "list", "(", "set", "(...
Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production.
[ "Return", "the", "resources", "from", "an", "API", "implementation", "module", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/__init__.py#L76-L85
train
Return the resources from an API implementation module.
weijia/djangoautoconf
djangoautoconf/django_adv_zip_template_loader.py
Loader.load_template_source
def load_template_source(self, template_name, template_dirs=None): """Template loader that loads templates from zipped modules.""" #Get every app's folder log.error("Calling zip loader") for folder in app_template_dirs: if ".zip/" in folder.replace("\\", "/"): ...
python
def load_template_source(self, template_name, template_dirs=None): """Template loader that loads templates from zipped modules.""" #Get every app's folder log.error("Calling zip loader") for folder in app_template_dirs: if ".zip/" in folder.replace("\\", "/"): ...
[ "def", "load_template_source", "(", "self", ",", "template_name", ",", "template_dirs", "=", "None", ")", ":", "#Get every app's folder", "log", ".", "error", "(", "\"Calling zip loader\"", ")", "for", "folder", "in", "app_template_dirs", ":", "if", "\".zip/\"", "...
Template loader that loads templates from zipped modules.
[ "Template", "loader", "that", "loads", "templates", "from", "zipped", "modules", "." ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/django_adv_zip_template_loader.py#L44-L71
train
Template loader that loads templates from zipped modules.
olitheolix/qtmacs
qtmacs/logging_handler.py
QtmacsLoggingHandler.emit
def emit(self, record): """ Overloaded emit() function from the logger module. The supplied log record is added to the log buffer and the sigNewLog signal triggered. .. note:: this method is always only called from the ``logger`` module. """ self.log.a...
python
def emit(self, record): """ Overloaded emit() function from the logger module. The supplied log record is added to the log buffer and the sigNewLog signal triggered. .. note:: this method is always only called from the ``logger`` module. """ self.log.a...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "self", ".", "log", ".", "append", "(", "record", ")", "# Do not trigger the signal again if no one has fetched any", "# data since it was last set.", "if", "not", "self", ".", "waitForFetch", ":", "self", ".", ...
Overloaded emit() function from the logger module. The supplied log record is added to the log buffer and the sigNewLog signal triggered. .. note:: this method is always only called from the ``logger`` module.
[ "Overloaded", "emit", "()", "function", "from", "the", "logger", "module", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/logging_handler.py#L109-L125
train
Overloaded emit function from the logger module.
olitheolix/qtmacs
qtmacs/logging_handler.py
QtmacsLoggingHandler.fetch
def fetch(self, start=None, stop=None): """ Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. ...
python
def fetch(self, start=None, stop=None): """ Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. ...
[ "def", "fetch", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "# Set defaults if no explicit indices were provided.", "if", "not", "start", ":", "start", "=", "0", "if", "not", "stop", ":", "stop", "=", "len", "(", "self", "...
Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. |Returns| * **list**: list of log records (see ``lo...
[ "Fetch", "log", "records", "and", "return", "them", "as", "a", "list", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/logging_handler.py#L127-L165
train
Fetch log records and return them as a list.
Loudr/pale
pale/adapters/flask.py
bind_blueprint
def bind_blueprint(pale_api_module, flask_blueprint): """Binds an implemented pale API module to a Flask Blueprint.""" if not isinstance(flask_blueprint, Blueprint): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in flask_blueprint to be an instance ...
python
def bind_blueprint(pale_api_module, flask_blueprint): """Binds an implemented pale API module to a Flask Blueprint.""" if not isinstance(flask_blueprint, Blueprint): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in flask_blueprint to be an instance ...
[ "def", "bind_blueprint", "(", "pale_api_module", ",", "flask_blueprint", ")", ":", "if", "not", "isinstance", "(", "flask_blueprint", ",", "Blueprint", ")", ":", "raise", "TypeError", "(", "(", "\"pale.flask_adapter.bind_blueprint expected the \"", "\"passed in flask_blue...
Binds an implemented pale API module to a Flask Blueprint.
[ "Binds", "an", "implemented", "pale", "API", "module", "to", "a", "Flask", "Blueprint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/adapters/flask.py#L29-L58
train
Binds an implemented pale API module to a Flask Blueprint.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.cookie_name_check
def cookie_name_check(cookie_name): """ Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool """ cookie_match = WHTTPCookie.cookie_name_non_compliance_re.match(cookie_name.encode('us-ascii')) return len(cookie_name) > 0 and cookie_match is None
python
def cookie_name_check(cookie_name): """ Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool """ cookie_match = WHTTPCookie.cookie_name_non_compliance_re.match(cookie_name.encode('us-ascii')) return len(cookie_name) > 0 and cookie_match is None
[ "def", "cookie_name_check", "(", "cookie_name", ")", ":", "cookie_match", "=", "WHTTPCookie", ".", "cookie_name_non_compliance_re", ".", "match", "(", "cookie_name", ".", "encode", "(", "'us-ascii'", ")", ")", "return", "len", "(", "cookie_name", ")", ">", "0", ...
Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool
[ "Check", "cookie", "name", "for", "validity", ".", "Return", "True", "if", "name", "is", "valid" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L66-L73
train
Check cookie name for validity. Return True if name is valid otherwise False
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.cookie_attr_value_check
def cookie_attr_value_check(attr_name, attr_value): """ Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool """ attr_value.encode('us-ascii') return WHTTPCookie.cookie_attr_value_compl...
python
def cookie_attr_value_check(attr_name, attr_value): """ Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool """ attr_value.encode('us-ascii') return WHTTPCookie.cookie_attr_value_compl...
[ "def", "cookie_attr_value_check", "(", "attr_name", ",", "attr_value", ")", ":", "attr_value", ".", "encode", "(", "'us-ascii'", ")", "return", "WHTTPCookie", ".", "cookie_attr_value_compliance", "[", "attr_name", "]", ".", "match", "(", "attr_value", ")", "is", ...
Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool
[ "Check", "cookie", "attribute", "value", "for", "validity", ".", "Return", "True", "if", "value", "is", "valid" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L85-L93
train
Check cookie attribute value for validity. Return True if value is valid otherwise False
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.value
def value(self, new_value=None): """ Return cookie value. Cookie value can be updated, when new_value is not None. Cookie value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param new_value: new value to set :return: str """ if new_value is not None: if self.__r...
python
def value(self, new_value=None): """ Return cookie value. Cookie value can be updated, when new_value is not None. Cookie value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param new_value: new value to set :return: str """ if new_value is not None: if self.__r...
[ "def", "value", "(", "self", ",", "new_value", "=", "None", ")", ":", "if", "new_value", "is", "not", "None", ":", "if", "self", ".", "__ro_flag", ":", "raise", "RuntimeError", "(", "'Read-only cookie changing attempt'", ")", "self", ".", "__value", "=", "...
Return cookie value. Cookie value can be updated, when new_value is not None. Cookie value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param new_value: new value to set :return: str
[ "Return", "cookie", "value", ".", "Cookie", "value", "can", "be", "updated", "when", "new_value", "is", "not", "None", ".", "Cookie", "value", "couldn", "t", "be", "changed", "if", "cookie", "is", "in", "read", "-", "only", "mode", "(", "RuntimeError", "...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L123-L134
train
Return cookie value.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.__attr_name
def __attr_name(self, name): """ Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str """ if name not in self.cookie_attr_value_compliance.keys(): suggested_name = name.re...
python
def __attr_name(self, name): """ Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str """ if name not in self.cookie_attr_value_compliance.keys(): suggested_name = name.re...
[ "def", "__attr_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "cookie_attr_value_compliance", ".", "keys", "(", ")", ":", "suggested_name", "=", "name", ".", "replace", "(", "'_'", ",", "'-'", ")", ".", "lower", "(",...
Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str
[ "Return", "suitable", "and", "valid", "attribute", "name", ".", "This", "method", "replaces", "dash", "char", "to", "underscore", ".", "If", "name", "is", "invalid", "ValueError", "exception", "is", "raised" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L145-L157
train
Return suitable and valid attribute name. This method replaces dash char to underscore.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.attr
def attr(self, attr_name, attr_value=None): """ Return attribute value. Attribute value can be updated with this method. In order to update attribute value attr_value must be set. Cookie attribute value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: tar...
python
def attr(self, attr_name, attr_value=None): """ Return attribute value. Attribute value can be updated with this method. In order to update attribute value attr_value must be set. Cookie attribute value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: tar...
[ "def", "attr", "(", "self", ",", "attr_name", ",", "attr_value", "=", "None", ")", ":", "name", "=", "self", ".", "__attr_name", "(", "attr_name", ")", "if", "attr_value", "is", "not", "None", ":", "if", "WHTTPCookie", ".", "cookie_attr_value_check", "(", ...
Return attribute value. Attribute value can be updated with this method. In order to update attribute value attr_value must be set. Cookie attribute value couldn't be changed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: target attribute name :param attr_value: new value ...
[ "Return", "attribute", "value", ".", "Attribute", "value", "can", "be", "updated", "with", "this", "method", ".", "In", "order", "to", "update", "attribute", "value", "attr_value", "must", "be", "set", ".", "Cookie", "attribute", "value", "couldn", "t", "be"...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L161-L178
train
Return attribute value.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.remove_attr
def remove_attr(self, attr_name): """ Remove cookie attribute. Cookie attribute couldn't be removed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: name of attribute to remove :return: None """ if self.__ro_flag: raise RuntimeError('Read-only cookie changing attempt'...
python
def remove_attr(self, attr_name): """ Remove cookie attribute. Cookie attribute couldn't be removed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: name of attribute to remove :return: None """ if self.__ro_flag: raise RuntimeError('Read-only cookie changing attempt'...
[ "def", "remove_attr", "(", "self", ",", "attr_name", ")", ":", "if", "self", ".", "__ro_flag", ":", "raise", "RuntimeError", "(", "'Read-only cookie changing attempt'", ")", "name", "=", "self", ".", "__attr_name", "(", "attr_name", ")", "if", "name", "in", ...
Remove cookie attribute. Cookie attribute couldn't be removed if cookie is in read-only mode (RuntimeError exception is raised). :param attr_name: name of attribute to remove :return: None
[ "Remove", "cookie", "attribute", ".", "Cookie", "attribute", "couldn", "t", "be", "removed", "if", "cookie", "is", "in", "read", "-", "only", "mode", "(", "RuntimeError", "exception", "is", "raised", ")", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L181-L192
train
Removes the specified attribute from the cookie.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.copy
def copy(self): """ Return copy :return: WHTTPCookie """ copy_cookie = WHTTPCookie(self.__name, self.__value) copy_cookie.__attrs = self.__attrs.copy() return copy_cookie
python
def copy(self): """ Return copy :return: WHTTPCookie """ copy_cookie = WHTTPCookie(self.__name, self.__value) copy_cookie.__attrs = self.__attrs.copy() return copy_cookie
[ "def", "copy", "(", "self", ")", ":", "copy_cookie", "=", "WHTTPCookie", "(", "self", ".", "__name", ",", "self", ".", "__value", ")", "copy_cookie", ".", "__attrs", "=", "self", ".", "__attrs", ".", "copy", "(", ")", "return", "copy_cookie" ]
Return copy :return: WHTTPCookie
[ "Return", "copy" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L214-L221
train
Return a copy of this cookie.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.add_cookie
def add_cookie(self, cookie): """ Add new cookie (or replace if there is cookie with the same name already) :param cookie: cookie to add :return: None """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') self.__cookies[cookie.name()] = cookie
python
def add_cookie(self, cookie): """ Add new cookie (or replace if there is cookie with the same name already) :param cookie: cookie to add :return: None """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') self.__cookies[cookie.name()] = cookie
[ "def", "add_cookie", "(", "self", ",", "cookie", ")", ":", "if", "self", ".", "__ro_flag", ":", "raise", "RuntimeError", "(", "'Read-only cookie-jar changing attempt'", ")", "self", ".", "__cookies", "[", "cookie", ".", "name", "(", ")", "]", "=", "cookie" ]
Add new cookie (or replace if there is cookie with the same name already) :param cookie: cookie to add :return: None
[ "Add", "new", "cookie", "(", "or", "replace", "if", "there", "is", "cookie", "with", "the", "same", "name", "already", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L243-L251
train
Add a cookie to the cookie jar.
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.remove_cookie
def remove_cookie(self, cookie_name): """ Remove cookie by its name :param cookie_name: cookie name :return: """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') if cookie_name in self.__cookies.keys(): self.__cookies.pop(cookie_name)
python
def remove_cookie(self, cookie_name): """ Remove cookie by its name :param cookie_name: cookie name :return: """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') if cookie_name in self.__cookies.keys(): self.__cookies.pop(cookie_name)
[ "def", "remove_cookie", "(", "self", ",", "cookie_name", ")", ":", "if", "self", ".", "__ro_flag", ":", "raise", "RuntimeError", "(", "'Read-only cookie-jar changing attempt'", ")", "if", "cookie_name", "in", "self", ".", "__cookies", ".", "keys", "(", ")", ":...
Remove cookie by its name :param cookie_name: cookie name :return:
[ "Remove", "cookie", "by", "its", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L254-L263
train
Removes a cookie by its name
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.ro
def ro(self): """ Return read-only copy :return: WHTTPCookieJar """ ro_jar = WHTTPCookieJar() for cookie in self.__cookies.values(): ro_jar.add_cookie(cookie.ro()) ro_jar.__ro_flag = True return ro_jar
python
def ro(self): """ Return read-only copy :return: WHTTPCookieJar """ ro_jar = WHTTPCookieJar() for cookie in self.__cookies.values(): ro_jar.add_cookie(cookie.ro()) ro_jar.__ro_flag = True return ro_jar
[ "def", "ro", "(", "self", ")", ":", "ro_jar", "=", "WHTTPCookieJar", "(", ")", "for", "cookie", "in", "self", ".", "__cookies", ".", "values", "(", ")", ":", "ro_jar", ".", "add_cookie", "(", "cookie", ".", "ro", "(", ")", ")", "ro_jar", ".", "__ro...
Return read-only copy :return: WHTTPCookieJar
[ "Return", "read", "-", "only", "copy" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L282-L291
train
Return read - only copy of this cookie jar
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.import_simple_cookie
def import_simple_cookie(cls, simple_cookie): """ Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar """ cookie_jar = WHTTPCookieJar() for cookie_name in simple_cookie.keys(): cookie_attrs = {} for attr_name in WHTTPCookie.cookie_attr_value_comp...
python
def import_simple_cookie(cls, simple_cookie): """ Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar """ cookie_jar = WHTTPCookieJar() for cookie_name in simple_cookie.keys(): cookie_attrs = {} for attr_name in WHTTPCookie.cookie_attr_value_comp...
[ "def", "import_simple_cookie", "(", "cls", ",", "simple_cookie", ")", ":", "cookie_jar", "=", "WHTTPCookieJar", "(", ")", "for", "cookie_name", "in", "simple_cookie", ".", "keys", "(", ")", ":", "cookie_attrs", "=", "{", "}", "for", "attr_name", "in", "WHTTP...
Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar
[ "Create", "cookie", "jar", "from", "SimpleCookie", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L295-L312
train
Create cookie jar from SimpleCookie object
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.import_header_text
def import_header_text(cls, cookie_text): """ Create cookie jar from HTTP Header text like 'Set-Cookie: cookie=value' :param cookie_text: http header code :return: WHTTPCookieJar """ simple_cookie = SimpleCookie() simple_cookie.load(cookie_text) return cls.import_simple_cookie(simple_cookie)
python
def import_header_text(cls, cookie_text): """ Create cookie jar from HTTP Header text like 'Set-Cookie: cookie=value' :param cookie_text: http header code :return: WHTTPCookieJar """ simple_cookie = SimpleCookie() simple_cookie.load(cookie_text) return cls.import_simple_cookie(simple_cookie)
[ "def", "import_header_text", "(", "cls", ",", "cookie_text", ")", ":", "simple_cookie", "=", "SimpleCookie", "(", ")", "simple_cookie", ".", "load", "(", "cookie_text", ")", "return", "cls", ".", "import_simple_cookie", "(", "simple_cookie", ")" ]
Create cookie jar from HTTP Header text like 'Set-Cookie: cookie=value' :param cookie_text: http header code :return: WHTTPCookieJar
[ "Create", "cookie", "jar", "from", "HTTP", "Header", "text", "like", "Set", "-", "Cookie", ":", "cookie", "=", "value" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L316-L324
train
Create cookie jar from HTTP header text like Set - Cookie = value
vecnet/vecnet.openmalaria
vecnet/openmalaria/helpers.py
is_prime
def is_prime(n): """ Check if n is a prime number """ if n % 2 == 0 and n > 2: return False return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
python
def is_prime(n): """ Check if n is a prime number """ if n % 2 == 0 and n > 2: return False return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
[ "def", "is_prime", "(", "n", ")", ":", "if", "n", "%", "2", "==", "0", "and", "n", ">", "2", ":", "return", "False", "return", "all", "(", "n", "%", "i", "for", "i", "in", "range", "(", "3", ",", "int", "(", "math", ".", "sqrt", "(", "n", ...
Check if n is a prime number
[ "Check", "if", "n", "is", "a", "prime", "number" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/helpers.py#L15-L21
train
Check if n is a prime number
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.scheme_specification
def scheme_specification(cls): """ :meth:`.WSchemeHandler.scheme_specification` method implementation """ return WSchemeSpecification( 'file', WURIComponentVerifier(WURI.Component.path, WURIComponentVerifier.Requirement.optional) )
python
def scheme_specification(cls): """ :meth:`.WSchemeHandler.scheme_specification` method implementation """ return WSchemeSpecification( 'file', WURIComponentVerifier(WURI.Component.path, WURIComponentVerifier.Requirement.optional) )
[ "def", "scheme_specification", "(", "cls", ")", ":", "return", "WSchemeSpecification", "(", "'file'", ",", "WURIComponentVerifier", "(", "WURI", ".", "Component", ".", "path", ",", "WURIComponentVerifier", ".", "Requirement", ".", "optional", ")", ")" ]
:meth:`.WSchemeHandler.scheme_specification` method implementation
[ ":", "meth", ":", ".", "WSchemeHandler", ".", "scheme_specification", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L77-L83
train
returns a WSchemeSpecification object that can be used to create a URL scheme.
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.change_directory
def change_directory(self, path, *args, **kwargs): """ :meth:`.WNetworkClientProto.change_directory` method implementation """ previous_path = self.session_path() self.session_path(path) if os.path.isdir(self.full_path()) is False: self.session_path(previous_path) raise ValueError('Unable to change dire...
python
def change_directory(self, path, *args, **kwargs): """ :meth:`.WNetworkClientProto.change_directory` method implementation """ previous_path = self.session_path() self.session_path(path) if os.path.isdir(self.full_path()) is False: self.session_path(previous_path) raise ValueError('Unable to change dire...
[ "def", "change_directory", "(", "self", ",", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "self", ".", "session_path", "(", "path", ")", "if", "os", ".", "path", ".", "isdir...
:meth:`.WNetworkClientProto.change_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "change_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L96-L103
train
method implementation . change_directory
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.make_directory
def make_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.make_directory` method implementation """ previous_path = self.session_path() try: self.session_path(directory_name) os.mkdir(self.full_path()) finally: self.session_path(previous_path)
python
def make_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.make_directory` method implementation """ previous_path = self.session_path() try: self.session_path(directory_name) os.mkdir(self.full_path()) finally: self.session_path(previous_path)
[ "def", "make_directory", "(", "self", ",", "directory_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "self", ".", "session_path", "(", "directory_name", ")", "os", ".",...
:meth:`.WNetworkClientProto.make_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "make_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L114-L122
train
method implementation os. mkdir - p
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.remove_directory
def remove_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_directory` method implementation """ previous_path = self.session_path() try: self.session_path(directory_name) os.rmdir(self.full_path()) finally: self.session_path(previous_path)
python
def remove_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_directory` method implementation """ previous_path = self.session_path() try: self.session_path(directory_name) os.rmdir(self.full_path()) finally: self.session_path(previous_path)
[ "def", "remove_directory", "(", "self", ",", "directory_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "self", ".", "session_path", "(", "directory_name", ")", "os", "....
:meth:`.WNetworkClientProto.remove_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "remove_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L127-L135
train
method implementation os. remove_directory
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.upload_file
def upload_file(self, file_name, file_obj, *args, **kwargs): """ :meth:`.WNetworkClientProto.upload_file` method implementation """ previous_path = self.session_path() try: self.session_path(file_name) with open(self.full_path(), mode='wb') as f: chunk = file_obj.read(io.DEFAULT_BUFFER_SIZE) while...
python
def upload_file(self, file_name, file_obj, *args, **kwargs): """ :meth:`.WNetworkClientProto.upload_file` method implementation """ previous_path = self.session_path() try: self.session_path(file_name) with open(self.full_path(), mode='wb') as f: chunk = file_obj.read(io.DEFAULT_BUFFER_SIZE) while...
[ "def", "upload_file", "(", "self", ",", "file_name", ",", "file_obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "self", ".", "session_path", "(", "file_name", ")", "wit...
:meth:`.WNetworkClientProto.upload_file` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "upload_file", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L140-L152
train
method implementation . upload_file
a1ezzz/wasp-general
wasp_general/network/clients/file.py
WLocalFileClient.remove_file
def remove_file(self, file_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_file` method implementation """ previous_path = self.session_path() try: self.session_path(file_name) os.unlink(self.full_path()) finally: self.session_path(previous_path)
python
def remove_file(self, file_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_file` method implementation """ previous_path = self.session_path() try: self.session_path(file_name) os.unlink(self.full_path()) finally: self.session_path(previous_path)
[ "def", "remove_file", "(", "self", ",", "file_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "self", ".", "session_path", "(", "file_name", ")", "os", ".", "unlink", ...
:meth:`.WNetworkClientProto.remove_file` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "remove_file", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L157-L165
train
method implementation . remove_file
olitheolix/qtmacs
qtmacs/applets/richeditor.py
RichEditor.loadFile
def loadFile(self, fileName): """ Display the file associated with the appletID. """ # Assign QFile object with the current name. self.file = QtCore.QFile(fileName) if self.file.exists(): self.qteText.append(open(fileName).read()) else: ms...
python
def loadFile(self, fileName): """ Display the file associated with the appletID. """ # Assign QFile object with the current name. self.file = QtCore.QFile(fileName) if self.file.exists(): self.qteText.append(open(fileName).read()) else: ms...
[ "def", "loadFile", "(", "self", ",", "fileName", ")", ":", "# Assign QFile object with the current name.", "self", ".", "file", "=", "QtCore", ".", "QFile", "(", "fileName", ")", "if", "self", ".", "file", ".", "exists", "(", ")", ":", "self", ".", "qteTex...
Display the file associated with the appletID.
[ "Display", "the", "file", "associated", "with", "the", "appletID", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/richeditor.py#L67-L78
train
Load the file and display it in the appletID.
olitheolix/qtmacs
qtmacs/applets/richeditor.py
RichEditor.displayStartupScreen
def displayStartupScreen(self): """ Display the Qtmacs logo (Max) together with the GPL. """ # Determine the path of the Qtmacs application because this is # also where the image file is located. path, _ = os.path.split(qtmacs.qtmacsmain.__file__) # Load the imag...
python
def displayStartupScreen(self): """ Display the Qtmacs logo (Max) together with the GPL. """ # Determine the path of the Qtmacs application because this is # also where the image file is located. path, _ = os.path.split(qtmacs.qtmacsmain.__file__) # Load the imag...
[ "def", "displayStartupScreen", "(", "self", ")", ":", "# Determine the path of the Qtmacs application because this is", "# also where the image file is located.", "path", ",", "_", "=", "os", ".", "path", ".", "split", "(", "qtmacs", ".", "qtmacsmain", ".", "__file__", ...
Display the Qtmacs logo (Max) together with the GPL.
[ "Display", "the", "Qtmacs", "logo", "(", "Max", ")", "together", "with", "the", "GPL", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/richeditor.py#L80-L97
train
Display the startup screen of the Qtmacs application.
jreese/ent
ent/ent.py
Ent._encode
def _encode(self): """Generate a recursive JSON representation of the ent.""" obj = {k: v for k, v in self.__dict__.items() if not k.startswith('_') and type(v) in SAFE_TYPES} obj.update({k: v._encode() for k, v in self.__dict__.items() if isinstance(v, Ent)}) ...
python
def _encode(self): """Generate a recursive JSON representation of the ent.""" obj = {k: v for k, v in self.__dict__.items() if not k.startswith('_') and type(v) in SAFE_TYPES} obj.update({k: v._encode() for k, v in self.__dict__.items() if isinstance(v, Ent)}) ...
[ "def", "_encode", "(", "self", ")", ":", "obj", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", "if", "not", "k", ".", "startswith", "(", "'_'", ")", "and", "type", "(", "v", ")", "in", ...
Generate a recursive JSON representation of the ent.
[ "Generate", "a", "recursive", "JSON", "representation", "of", "the", "ent", "." ]
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L81-L87
train
Generate a recursive JSON representation of the ent.
jreese/ent
ent/ent.py
Ent.load
def load(cls, data, promote=False): """Create a new ent from an existing value. The value must either be an instance of Ent, or must be an instance of SAFE_TYPES. If the value is a base type (bool, int, string, etc), it will just be returned. Iterable types will be loaded recursively,...
python
def load(cls, data, promote=False): """Create a new ent from an existing value. The value must either be an instance of Ent, or must be an instance of SAFE_TYPES. If the value is a base type (bool, int, string, etc), it will just be returned. Iterable types will be loaded recursively,...
[ "def", "load", "(", "cls", ",", "data", ",", "promote", "=", "False", ")", ":", "t", "=", "type", "(", "data", ")", "if", "t", "==", "cls", ":", "# same class, create new copy", "return", "cls", "(", "{", "k", ":", "cls", ".", "load", "(", "v", "...
Create a new ent from an existing value. The value must either be an instance of Ent, or must be an instance of SAFE_TYPES. If the value is a base type (bool, int, string, etc), it will just be returned. Iterable types will be loaded recursively, transforming dictionaries into Ent ins...
[ "Create", "a", "new", "ent", "from", "an", "existing", "value", ".", "The", "value", "must", "either", "be", "an", "instance", "of", "Ent", "or", "must", "be", "an", "instance", "of", "SAFE_TYPES", ".", "If", "the", "value", "is", "a", "base", "type", ...
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L94-L130
train
Create a new Ent instance from an existing value.
jreese/ent
ent/ent.py
Ent.merge
def merge(cls, *args, **kwargs): """Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recogn...
python
def merge(cls, *args, **kwargs): """Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recogn...
[ "def", "merge", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "newkeys", "=", "bool", "(", "kwargs", ".", "get", "(", "'newkeys'", ",", "False", ")", ")", "ignore", "=", "kwargs", ".", "get", "(", "'ignore'", ",", "list", "(", ...
Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recognized: newkeys: boolean value to det...
[ "Create", "a", "new", "Ent", "from", "one", "or", "more", "existing", "Ents", ".", "Keys", "in", "the", "later", "Ent", "objects", "will", "overwrite", "the", "keys", "of", "the", "previous", "Ents", ".", "Later", "keys", "of", "different", "type", "than...
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L133-L176
train
Create a new Ent from one or more existing Ents.
jreese/ent
ent/ent.py
Ent.diff
def diff(cls, *args, **kwargs): """Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type tha...
python
def diff(cls, *args, **kwargs): """Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type tha...
[ "def", "diff", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "newkeys", "=", "bool", "(", "kwargs", ".", "get", "(", "'newkeys'", ",", "False", ")", ")", "ignore", "=", "kwargs", ".", "get", "(", "'ignore'", ",", "list", "(", ...
Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type than in earlier Ents will be bravely i...
[ "Create", "a", "new", "Ent", "representing", "the", "differences", "in", "two", "or", "more", "existing", "Ents", ".", "Keys", "in", "the", "later", "Ents", "with", "values", "that", "differ", "from", "the", "earlier", "Ents", "will", "be", "present", "in"...
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L179-L226
train
Create a new Ent representing the differences in two or more Ents.
jreese/ent
ent/ent.py
Ent.subclasses
def subclasses(cls): """Return a set of all Ent subclasses, recursively.""" seen = set() queue = set([cls]) while queue: c = queue.pop() seen.add(c) sc = c.__subclasses__() for c in sc: if c not in seen: ...
python
def subclasses(cls): """Return a set of all Ent subclasses, recursively.""" seen = set() queue = set([cls]) while queue: c = queue.pop() seen.add(c) sc = c.__subclasses__() for c in sc: if c not in seen: ...
[ "def", "subclasses", "(", "cls", ")", ":", "seen", "=", "set", "(", ")", "queue", "=", "set", "(", "[", "cls", "]", ")", "while", "queue", ":", "c", "=", "queue", ".", "pop", "(", ")", "seen", ".", "add", "(", "c", ")", "sc", "=", "c", ".",...
Return a set of all Ent subclasses, recursively.
[ "Return", "a", "set", "of", "all", "Ent", "subclasses", "recursively", "." ]
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L229-L244
train
Return a set of all Ent subclasses recursively.
atl/py-smartdc
smartdc/datacenter.py
deprecated
def deprecated(func): '''This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used. https://wiki.python.org/moin/PythonDecoratorLibrary#Generating_Deprecation_Warnings ''' def new_func(*args, **kwargs): ...
python
def deprecated(func): '''This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used. https://wiki.python.org/moin/PythonDecoratorLibrary#Generating_Deprecation_Warnings ''' def new_func(*args, **kwargs): ...
[ "def", "deprecated", "(", "func", ")", ":", "def", "new_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warn", "(", "\"Call to deprecated function {}.\"", ".", "format", "(", "func", ".", "__name__", ")", ",", "category", "=", "DeprecationWarn...
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used. https://wiki.python.org/moin/PythonDecoratorLibrary#Generating_Deprecation_Warnings
[ "This", "is", "a", "decorator", "which", "can", "be", "used", "to", "mark", "functions", "as", "deprecated", ".", "It", "will", "result", "in", "a", "warning", "being", "emitted", "when", "the", "function", "is", "used", ".", "https", ":", "//", "wiki", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L47-L61
train
A function decorator which marks functions as deprecated.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.base_url
def base_url(self): """Protocol + hostname""" if self.location in self.known_locations: return self.known_locations[self.location] elif '.' in self.location or self.location == 'localhost': return 'https://' + self.location else: return 'https://' + se...
python
def base_url(self): """Protocol + hostname""" if self.location in self.known_locations: return self.known_locations[self.location] elif '.' in self.location or self.location == 'localhost': return 'https://' + self.location else: return 'https://' + se...
[ "def", "base_url", "(", "self", ")", ":", "if", "self", ".", "location", "in", "self", ".", "known_locations", ":", "return", "self", ".", "known_locations", "[", "self", ".", "location", "]", "elif", "'.'", "in", "self", ".", "location", "or", "self", ...
Protocol + hostname
[ "Protocol", "+", "hostname" ]
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L201-L208
train
Returns the base URL for the given resource.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.authenticate
def authenticate(self, key_id=None, secret=None, allow_agent=False): """ :param key_id: SmartDC identifier for the ssh key :type key_id: :py:class:`basestring` :param secret: path to private rsa key :type secret: :py:class:`basestring` :param allow_agent...
python
def authenticate(self, key_id=None, secret=None, allow_agent=False): """ :param key_id: SmartDC identifier for the ssh key :type key_id: :py:class:`basestring` :param secret: path to private rsa key :type secret: :py:class:`basestring` :param allow_agent...
[ "def", "authenticate", "(", "self", ",", "key_id", "=", "None", ",", "secret", "=", "None", ",", "allow_agent", "=", "False", ")", ":", "if", "key_id", "and", "secret", ":", "self", ".", "auth", "=", "HTTPSignatureAuth", "(", "key_id", "=", "key_id", "...
:param key_id: SmartDC identifier for the ssh key :type key_id: :py:class:`basestring` :param secret: path to private rsa key :type secret: :py:class:`basestring` :param allow_agent: whether or not to try ssh-agent :type allow_agent: :py:class:`bool` ...
[ ":", "param", "key_id", ":", "SmartDC", "identifier", "for", "the", "ssh", "key", ":", "type", "key_id", ":", ":", "py", ":", "class", ":", "basestring", ":", "param", "secret", ":", "path", "to", "private", "rsa", "key", ":", "type", "secret", ":", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L210-L227
train
Authenticate with a key_id and secret.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.request
def request(self, method, path, headers=None, data=None, **kwargs): """ (Primarily) internal method for making all requests to the datacenter. :param method: HTTP verb :type method: :py:class:`str` :param path: path relative to `login` path :type path: :...
python
def request(self, method, path, headers=None, data=None, **kwargs): """ (Primarily) internal method for making all requests to the datacenter. :param method: HTTP verb :type method: :py:class:`str` :param path: path relative to `login` path :type path: :...
[ "def", "request", "(", "self", ",", "method", ",", "path", ",", "headers", "=", "None", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "full_path", "=", "self", ".", "url", "+", "path", "request_headers", "=", "{", "}", "request_headers...
(Primarily) internal method for making all requests to the datacenter. :param method: HTTP verb :type method: :py:class:`str` :param path: path relative to `login` path :type path: :py:class:`str` :param headers: additional headers to send :type...
[ "(", "Primarily", ")", "internal", "method", "for", "making", "all", "requests", "to", "the", "datacenter", ".", ":", "param", "method", ":", "HTTP", "verb", ":", "type", "method", ":", ":", "py", ":", "class", ":", "str", ":", "param", "path", ":", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L229-L275
train
Internal method for making all requests to the datacenter.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.api
def api(self): """ .. warning:: Deprecated: will be withdrawn since JPC doesn't appear to return the nice documentation object any more :: GET / :Returns: a programmatically-generated API summary using HTTP verbs and URL tem...
python
def api(self): """ .. warning:: Deprecated: will be withdrawn since JPC doesn't appear to return the nice documentation object any more :: GET / :Returns: a programmatically-generated API summary using HTTP verbs and URL tem...
[ "def", "api", "(", "self", ")", ":", "if", "self", ".", "verbose", ":", "print", "(", "\"%s\\t%s\\t%s\"", "%", "(", "datetime", ".", "now", "(", ")", ".", "isoformat", "(", ")", ",", "'GET'", ",", "self", ".", "base_url", ")", ",", "file", "=", "...
.. warning:: Deprecated: will be withdrawn since JPC doesn't appear to return the nice documentation object any more :: GET / :Returns: a programmatically-generated API summary using HTTP verbs and URL templates :rtype: :py:class:`d...
[ "..", "warning", "::", "Deprecated", ":", "will", "be", "withdrawn", "since", "JPC", "doesn", "t", "appear", "to", "return", "the", "nice", "documentation", "object", "any", "more", "::", "GET", "/", ":", "Returns", ":", "a", "programmatically", "-", "gene...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L278-L299
train
Returns a programmatically - generated API summary using HTTP verbs and URL templates
atl/py-smartdc
smartdc/datacenter.py
DataCenter.account
def account(self): """ :: GET /:login :Returns: basic information about the authenticated account :rtype: :py:class:`dict` """ j, _ = self.request('GET', '') if 'login' in j and self.login == 'my': self.login = j['login'] ...
python
def account(self): """ :: GET /:login :Returns: basic information about the authenticated account :rtype: :py:class:`dict` """ j, _ = self.request('GET', '') if 'login' in j and self.login == 'my': self.login = j['login'] ...
[ "def", "account", "(", "self", ")", ":", "j", ",", "_", "=", "self", ".", "request", "(", "'GET'", ",", "''", ")", "if", "'login'", "in", "j", "and", "self", ".", "login", "==", "'my'", ":", "self", ".", "login", "=", "j", "[", "'login'", "]", ...
:: GET /:login :Returns: basic information about the authenticated account :rtype: :py:class:`dict`
[ "::", "GET", "/", ":", "login", ":", "Returns", ":", "basic", "information", "about", "the", "authenticated", "account", ":", "rtype", ":", ":", "py", ":", "class", ":", "dict" ]
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L306-L318
train
Returns basic information about the authenticated account
atl/py-smartdc
smartdc/datacenter.py
DataCenter.update_account
def update_account(self, email=None, company_name=None, first_name=None, last_name=None, address=None, postal_code=None, city=None, state=None, country=None, phone=None): """ :: POST /:login :param email: Email address :type email: :...
python
def update_account(self, email=None, company_name=None, first_name=None, last_name=None, address=None, postal_code=None, city=None, state=None, country=None, phone=None): """ :: POST /:login :param email: Email address :type email: :...
[ "def", "update_account", "(", "self", ",", "email", "=", "None", ",", "company_name", "=", "None", ",", "first_name", "=", "None", ",", "last_name", "=", "None", ",", "address", "=", "None", ",", "postal_code", "=", "None", ",", "city", "=", "None", ",...
:: POST /:login :param email: Email address :type email: :py:class:`basestring` :param company_name: Company name :type company_name: :py:class:`basestring` :param first_name: First name :type first_name: :py:class:`basestri...
[ "::", "POST", "/", ":", "login", ":", "param", "email", ":", "Email", "address", ":", "type", "email", ":", ":", "py", ":", "class", ":", "basestring", ":", "param", "company_name", ":", "Company", "name", ":", "type", "company_name", ":", ":", "py", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L320-L383
train
Update the account info in the current node.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.key
def key(self, key_id): """ :: GET /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` :returns: details of the key :rtype: :py:class:`dict` """ ...
python
def key(self, key_id): """ :: GET /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` :returns: details of the key :rtype: :py:class:`dict` """ ...
[ "def", "key", "(", "self", ",", "key_id", ")", ":", "j", ",", "_", "=", "self", ".", "request", "(", "'GET'", ",", "'/keys/'", "+", "str", "(", "key_id", ")", ")", "return", "j" ]
:: GET /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` :returns: details of the key :rtype: :py:class:`dict`
[ "::", "GET", "/", ":", "login", "/", "keys", "/", ":", "key", ":", "param", "key_id", ":", "identifier", "for", "an", "individual", "key", "record", "for", "the", "account", ":", "type", "key_id", ":", ":", "py", ":", "class", ":", "basestring", ":",...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L397-L410
train
Gets the details of a key record for a given key id
atl/py-smartdc
smartdc/datacenter.py
DataCenter.add_key
def add_key(self, key_id, key): """ :: POST /:login/keys :param key_id: label for the new key :type key_id: :py:class:`basestring` :param key: the full SSH RSA public key :type key: :py:class:`str` Uploads a public k...
python
def add_key(self, key_id, key): """ :: POST /:login/keys :param key_id: label for the new key :type key_id: :py:class:`basestring` :param key: the full SSH RSA public key :type key: :py:class:`str` Uploads a public k...
[ "def", "add_key", "(", "self", ",", "key_id", ",", "key", ")", ":", "data", "=", "{", "'name'", ":", "str", "(", "key_id", ")", ",", "'key'", ":", "str", "(", "key", ")", "}", "j", ",", "_", "=", "self", ".", "request", "(", "'POST'", ",", "'...
:: POST /:login/keys :param key_id: label for the new key :type key_id: :py:class:`basestring` :param key: the full SSH RSA public key :type key: :py:class:`str` Uploads a public key to be added to the account's credentials.
[ "::", "POST", "/", ":", "login", "/", "keys", ":", "param", "key_id", ":", "label", "for", "the", "new", "key", ":", "type", "key_id", ":", ":", "py", ":", "class", ":", "basestring", ":", "param", "key", ":", "the", "full", "SSH", "RSA", "public",...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L412-L428
train
Adds a public key to the account s credentials.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.delete_key
def delete_key(self, key_id): """ :: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. """ ...
python
def delete_key(self, key_id): """ :: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. """ ...
[ "def", "delete_key", "(", "self", ",", "key_id", ")", ":", "j", ",", "r", "=", "self", ".", "request", "(", "'DELETE'", ",", "'/keys/'", "+", "str", "(", "key_id", ")", ")", "r", ".", "raise_for_status", "(", ")", "return", "j" ]
:: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`.
[ "::", "DELETE", "/", ":", "login", "/", "keys", "/", ":", "key", ":", "param", "key_id", ":", "identifier", "for", "an", "individual", "key", "record", "for", "the", "account", ":", "type", "key_id", ":", ":", "py", ":", "class", ":", "basestring", "...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L430-L443
train
This method deletes an SSH key from the server identified by key_id.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.datacenters
def datacenters(self): """ :: GET /:login/datacenters :Returns: all datacenters (mapping from short location key to full URL) that this cloud is aware of :rtype: :py:class:`dict` This method also updates the local `known_locatio...
python
def datacenters(self): """ :: GET /:login/datacenters :Returns: all datacenters (mapping from short location key to full URL) that this cloud is aware of :rtype: :py:class:`dict` This method also updates the local `known_locatio...
[ "def", "datacenters", "(", "self", ")", ":", "j", ",", "_", "=", "self", ".", "request", "(", "'GET'", ",", "'/datacenters'", ")", "self", ".", "known_locations", ".", "update", "(", "j", ")", "return", "j" ]
:: GET /:login/datacenters :Returns: all datacenters (mapping from short location key to full URL) that this cloud is aware of :rtype: :py:class:`dict` This method also updates the local `known_locations` attribute based upon this info...
[ "::", "GET", "/", ":", "login", "/", "datacenters", ":", "Returns", ":", "all", "datacenters", "(", "mapping", "from", "short", "location", "key", "to", "full", "URL", ")", "that", "this", "cloud", "is", "aware", "of", ":", "rtype", ":", ":", "py", "...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L445-L460
train
This method returns a dictionary of all datacenters that this cloud is aware of.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.datacenter
def datacenter(self, name): """ :param name: location key :type name: :py:class:`basestring` :Returns: a new DataCenter object This method treats the 'name' argument as a location key (on the `known_locations` attribute dict) or FQDN, and keeps existing...
python
def datacenter(self, name): """ :param name: location key :type name: :py:class:`basestring` :Returns: a new DataCenter object This method treats the 'name' argument as a location key (on the `known_locations` attribute dict) or FQDN, and keeps existing...
[ "def", "datacenter", "(", "self", ",", "name", ")", ":", "# The base form of this, as below, simply sets up a redirect. ", "# j, _ = self.request('GET', 'datacenters/' + str(name))", "if", "name", "not", "in", "self", ".", "known_locations", "and", "'.'", "not", "in", "name...
:param name: location key :type name: :py:class:`basestring` :Returns: a new DataCenter object This method treats the 'name' argument as a location key (on the `known_locations` attribute dict) or FQDN, and keeps existing authentication and other configuration...
[ ":", "param", "name", ":", "location", "key", ":", "type", "name", ":", ":", "py", ":", "class", ":", "basestring", ":", "Returns", ":", "a", "new", "DataCenter", "object", "This", "method", "treats", "the", "name", "argument", "as", "a", "location", "...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L462-L481
train
Returns a new object with the given location key.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.packages
def packages(self, name=None, memory=None, disk=None, swap=None, version=None, vcpus=None, group=None): """ :: GET /:login/packages :param name: the label associated with the resource package :type name: :py:class:`basestring` ...
python
def packages(self, name=None, memory=None, disk=None, swap=None, version=None, vcpus=None, group=None): """ :: GET /:login/packages :param name: the label associated with the resource package :type name: :py:class:`basestring` ...
[ "def", "packages", "(", "self", ",", "name", "=", "None", ",", "memory", "=", "None", ",", "disk", "=", "None", ",", "swap", "=", "None", ",", "version", "=", "None", ",", "vcpus", "=", "None", ",", "group", "=", "None", ")", ":", "params", "=", ...
:: GET /:login/packages :param name: the label associated with the resource package :type name: :py:class:`basestring` :param memory: amount of RAM (in MiB) that the package provisions :type memory: :py:class:`int` :param disk: amou...
[ "::", "GET", "/", ":", "login", "/", "packages", ":", "param", "name", ":", "the", "label", "associated", "with", "the", "resource", "package", ":", "type", "name", ":", ":", "py", ":", "class", ":", "basestring", ":", "param", "memory", ":", "amount",...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L528-L576
train
Gets the packages of the specified resource.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.default_package
def default_package(self): """ :: GET /:login/packages :Returns: the default package for this datacenter :rtype: :py:class:`dict` or ``None`` Requests all the packages in this datacenter, filters for the default, and returns the cor...
python
def default_package(self): """ :: GET /:login/packages :Returns: the default package for this datacenter :rtype: :py:class:`dict` or ``None`` Requests all the packages in this datacenter, filters for the default, and returns the cor...
[ "def", "default_package", "(", "self", ")", ":", "packages", "=", "[", "pk", "for", "pk", "in", "self", ".", "packages", "(", ")", "if", "pk", ".", "get", "(", "'default'", ")", "==", "'true'", "]", "if", "packages", ":", "return", "packages", "[", ...
:: GET /:login/packages :Returns: the default package for this datacenter :rtype: :py:class:`dict` or ``None`` Requests all the packages in this datacenter, filters for the default, and returns the corresponding dict, if a default has been defined.
[ "::", "GET", "/", ":", "login", "/", "packages", ":", "Returns", ":", "the", "default", "package", "for", "this", "datacenter", ":", "rtype", ":", ":", "py", ":", "class", ":", "dict", "or", "None", "Requests", "all", "the", "packages", "in", "this", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L578-L595
train
Returns the default package for this datacenter if it has been defined.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.package
def package(self, name): """ :: GET /:login/packages/:package :param name: the name identifying the package :type dataset_id: :py:class:`basestring` or :py:class:`dict` :rtype: :py:class:`dict` Gets a dict representing resou...
python
def package(self, name): """ :: GET /:login/packages/:package :param name: the name identifying the package :type dataset_id: :py:class:`basestring` or :py:class:`dict` :rtype: :py:class:`dict` Gets a dict representing resou...
[ "def", "package", "(", "self", ",", "name", ")", ":", "if", "isinstance", "(", "name", ",", "dict", ")", ":", "name", "=", "name", ".", "get", "(", "'id'", ",", "name", ".", "get", "(", "'name'", ")", ")", "j", ",", "_", "=", "self", ".", "re...
:: GET /:login/packages/:package :param name: the name identifying the package :type dataset_id: :py:class:`basestring` or :py:class:`dict` :rtype: :py:class:`dict` Gets a dict representing resource values for a package by name. If ...
[ "::", "GET", "/", ":", "login", "/", "packages", "/", ":", "package", ":", "param", "name", ":", "the", "name", "identifying", "the", "package", ":", "type", "dataset_id", ":", ":", "py", ":", "class", ":", "basestring", "or", ":", "py", ":", "class"...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L597-L615
train
Gets the resource values for a package by name.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.num_machines
def num_machines(self, machine_type=None, dataset=None, state=None, memory=None, tombstone=None, tags=None): """ :: HEAD /:login/machines Counts the number of machines total, or that match the predicates as with :py:meth:`machines`. ...
python
def num_machines(self, machine_type=None, dataset=None, state=None, memory=None, tombstone=None, tags=None): """ :: HEAD /:login/machines Counts the number of machines total, or that match the predicates as with :py:meth:`machines`. ...
[ "def", "num_machines", "(", "self", ",", "machine_type", "=", "None", ",", "dataset", "=", "None", ",", "state", "=", "None", ",", "memory", "=", "None", ",", "tombstone", "=", "None", ",", "tags", "=", "None", ")", ":", "_", ",", "r", "=", "self",...
:: HEAD /:login/machines Counts the number of machines total, or that match the predicates as with :py:meth:`machines`. :param machine_type: virtualmachine or smartmachine :type machine_type: :py:class:`basestring` :param dataset: u...
[ "::", "HEAD", "/", ":", "login", "/", "machines", "Counts", "the", "number", "of", "machines", "total", "or", "that", "match", "the", "predicates", "as", "with", ":", "py", ":", "meth", ":", "machines", ".", ":", "param", "machine_type", ":", "virtualmac...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L617-L651
train
Count the number of machines in this datacenter.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.raw_machine_data
def raw_machine_data(self, machine_id, credentials=False): """ :: GET /:login/machines/:machine :param machine_id: identifier for the machine instance :type machine_id: :py:class:`basestring` or :py:class:`dict` :param credentials: whether t...
python
def raw_machine_data(self, machine_id, credentials=False): """ :: GET /:login/machines/:machine :param machine_id: identifier for the machine instance :type machine_id: :py:class:`basestring` or :py:class:`dict` :param credentials: whether t...
[ "def", "raw_machine_data", "(", "self", ",", "machine_id", ",", "credentials", "=", "False", ")", ":", "params", "=", "{", "}", "if", "isinstance", "(", "machine_id", ",", "dict", ")", ":", "machine_id", "=", "machine_id", "[", "'id'", "]", "if", "creden...
:: GET /:login/machines/:machine :param machine_id: identifier for the machine instance :type machine_id: :py:class:`basestring` or :py:class:`dict` :param credentials: whether the SDC should return machine credentials :type credentials: :py:class:`...
[ "::", "GET", "/", ":", "login", "/", "machines", "/", ":", "machine", ":", "param", "machine_id", ":", "identifier", "for", "the", "machine", "instance", ":", "type", "machine_id", ":", ":", "py", ":", "class", ":", "basestring", "or", ":", "py", ":", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L653-L676
train
Get the raw data for a single machine.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.machines
def machines(self, machine_type=None, name=None, dataset=None, state=None, memory=None, tombstone=None, tags=None, credentials=False, paged=False, limit=None, offset=None): """ :: GET /:login/machines Query for machines in the current DataC...
python
def machines(self, machine_type=None, name=None, dataset=None, state=None, memory=None, tombstone=None, tags=None, credentials=False, paged=False, limit=None, offset=None): """ :: GET /:login/machines Query for machines in the current DataC...
[ "def", "machines", "(", "self", ",", "machine_type", "=", "None", ",", "name", "=", "None", ",", "dataset", "=", "None", ",", "state", "=", "None", ",", "memory", "=", "None", ",", "tombstone", "=", "None", ",", "tags", "=", "None", ",", "credentials...
:: GET /:login/machines Query for machines in the current DataCenter matching the input criteria, returning a :py:class:`list` of instantiated :py:class:`smartdc.machine.Machine` objects. :param machine_type: virtualmachine or smartmachine ...
[ "::", "GET", "/", ":", "login", "/", "machines", "Query", "for", "machines", "in", "the", "current", "DataCenter", "matching", "the", "input", "criteria", "returning", "a", ":", "py", ":", "class", ":", "list", "of", "instantiated", ":", "py", ":", "clas...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L678-L773
train
A method that returns a list of the machines in the current DataCenter that match the input parameters.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.create_machine
def create_machine(self, name=None, package=None, dataset=None, metadata=None, tags=None, boot_script=None, credentials=False, image=None, networks=None): """ :: POST /:login/machines Provision a machine in the current :py:class:`sma...
python
def create_machine(self, name=None, package=None, dataset=None, metadata=None, tags=None, boot_script=None, credentials=False, image=None, networks=None): """ :: POST /:login/machines Provision a machine in the current :py:class:`sma...
[ "def", "create_machine", "(", "self", ",", "name", "=", "None", ",", "package", "=", "None", ",", "dataset", "=", "None", ",", "metadata", "=", "None", ",", "tags", "=", "None", ",", "boot_script", "=", "None", ",", "credentials", "=", "False", ",", ...
:: POST /:login/machines Provision a machine in the current :py:class:`smartdc.datacenter.DataCenter`, returning an instantiated :py:class:`smartdc.machine.Machine` object. All of the parameter values are optional, as they are assigned default values by t...
[ "::", "POST", "/", ":", "login", "/", "machines", "Provision", "a", "machine", "in", "the", "current", ":", "py", ":", "class", ":", "smartdc", ".", "datacenter", ".", "DataCenter", "returning", "an", "instantiated", ":", "py", ":", "class", ":", "smartd...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L775-L860
train
Create a new machine in the current active resource store.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.machine
def machine(self, machine_id, credentials=False): """ :: GET /:login/machines/:id :param machine_id: unique identifier for a machine to be found in the datacenter :type machine_id: :py:class:`basestring` :rtype: :py:class:`smart...
python
def machine(self, machine_id, credentials=False): """ :: GET /:login/machines/:id :param machine_id: unique identifier for a machine to be found in the datacenter :type machine_id: :py:class:`basestring` :rtype: :py:class:`smart...
[ "def", "machine", "(", "self", ",", "machine_id", ",", "credentials", "=", "False", ")", ":", "if", "isinstance", "(", "machine_id", ",", "dict", ")", ":", "machine_id", "=", "machine_id", "[", "'id'", "]", "elif", "isinstance", "(", "machine_id", ",", "...
:: GET /:login/machines/:id :param machine_id: unique identifier for a machine to be found in the datacenter :type machine_id: :py:class:`basestring` :rtype: :py:class:`smartdc.machine.Machine`
[ "::", "GET", "/", ":", "login", "/", "machines", "/", ":", "id", ":", "param", "machine_id", ":", "unique", "identifier", "for", "a", "machine", "to", "be", "found", "in", "the", "datacenter", ":", "type", "machine_id", ":", ":", "py", ":", "class", ...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L862-L879
train
Gets a single machine from the given ID.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.networks
def networks(self, search=None, fields=('name,')): """ :: GET /:login/networks :param search: optionally filter (locally) with a regular expression search on the listed fields :type search: :py:class:`basestring` that compiles as a regular ...
python
def networks(self, search=None, fields=('name,')): """ :: GET /:login/networks :param search: optionally filter (locally) with a regular expression search on the listed fields :type search: :py:class:`basestring` that compiles as a regular ...
[ "def", "networks", "(", "self", ",", "search", "=", "None", ",", "fields", "=", "(", "'name,'", ")", ")", ":", "j", ",", "_", "=", "self", ".", "request", "(", "'GET'", ",", "'/networks'", ")", "if", "search", ":", "return", "list", "(", "search_di...
:: GET /:login/networks :param search: optionally filter (locally) with a regular expression search on the listed fields :type search: :py:class:`basestring` that compiles as a regular expression :param fields: filter on the listed f...
[ "::", "GET", "/", ":", "login", "/", "networks", ":", "param", "search", ":", "optionally", "filter", "(", "locally", ")", "with", "a", "regular", "expression", "search", "on", "the", "listed", "fields", ":", "type", "search", ":", ":", "py", ":", "cla...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L881-L904
train
GET / : login / networks GET / : login / networks
atl/py-smartdc
smartdc/datacenter.py
DataCenter.network
def network(self, identifier): """ :: GET /:login/networks/:id :param identifier: match on the listed network identifier :type identifier: :py:class:`basestring` or :py:class:`dict` :Returns: characteristics of the requested network ...
python
def network(self, identifier): """ :: GET /:login/networks/:id :param identifier: match on the listed network identifier :type identifier: :py:class:`basestring` or :py:class:`dict` :Returns: characteristics of the requested network ...
[ "def", "network", "(", "self", ",", "identifier", ")", ":", "if", "isinstance", "(", "identifier", ",", "dict", ")", ":", "identifier", "=", "identifier", ".", "get", "(", "'id'", ")", "j", ",", "_", "=", "self", ".", "request", "(", "'GET'", ",", ...
:: GET /:login/networks/:id :param identifier: match on the listed network identifier :type identifier: :py:class:`basestring` or :py:class:`dict` :Returns: characteristics of the requested network :rtype: :py:class:`dict` Either a ...
[ "::", "GET", "/", ":", "login", "/", "networks", "/", ":", "id", ":", "param", "identifier", ":", "match", "on", "the", "listed", "network", "identifier", ":", "type", "identifier", ":", ":", "py", ":", "class", ":", "basestring", "or", ":", "py", ":...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L906-L924
train
Gets the characteristics of the specified network.
atl/py-smartdc
smartdc/datacenter.py
DataCenter.images
def images(self, name=None, os=None, version=None, public=None, state=None, owner=None, type=None): """ :: GET /:login/images :param name: match on the listed name :type name: :py:class:`basestring` :param os: match on the s...
python
def images(self, name=None, os=None, version=None, public=None, state=None, owner=None, type=None): """ :: GET /:login/images :param name: match on the listed name :type name: :py:class:`basestring` :param os: match on the s...
[ "def", "images", "(", "self", ",", "name", "=", "None", ",", "os", "=", "None", ",", "version", "=", "None", ",", "public", "=", "None", ",", "state", "=", "None", ",", "owner", "=", "None", ",", "type", "=", "None", ")", ":", "params", "=", "{...
:: GET /:login/images :param name: match on the listed name :type name: :py:class:`basestring` :param os: match on the selected os :type os: :py:class:`basestring` :param version: match on the selected version :type version:...
[ "::", "GET", "/", ":", "login", "/", "images", ":", "param", "name", ":", "match", "on", "the", "listed", "name", ":", "type", "name", ":", ":", "py", ":", "class", ":", "basestring", ":", "param", "os", ":", "match", "on", "the", "selected", "os",...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L926-L975
train
This method returns a list of available machine images in this datacenter.