text
stringlengths
0
828
Get string and tuple versions from installed package information
It will return :attr:`default_string` and :attr:`default_tuple` values when
the named package is not installed.
Parameters
-----------
name : string
An application name used to install via setuptools.
default : string
A default returning value used when the named application is not
installed yet
default_tuple : tuple
A default returning value used when the named application is not
installed yet
allow_ambiguous : boolean
``True`` for allowing ambiguous version information.
Returns
--------
tuple
A version string and version tuple
Examples
--------
>>> import re
>>> v1, v2 = get_versions('app_version', allow_ambiguous=True)
>>> isinstance(v1, str)
True
>>> isinstance(v2, tuple)
True
>>> get_versions('distribution_which_is_not_installed')
('Please install this application with setup.py', (0, 0, 0))
""""""
version_string = get_string_version(name, default_string, allow_ambiguous)
version_tuple = get_tuple_version(name, default_tuple, allow_ambiguous)
return version_string, version_tuple"
4000,"def _get_toSymbol(cls):
# type: (_MetaRule) -> object
""""""
Get symbol from which the rule is rewrote.
:param cls: Rule for which return the symbol.
:return: Symbol from which the rule is rewrote.
:raise RuleNotDefinedException: If the rule is not defined.
:raise CantCreateSingleRuleException: If the rule consists of more rules.
:raise NotASingleSymbolException: If number of symbols on the left is more.
""""""
if cls._traverse:
raise RuleNotDefinedException(cls)
if len(cls.rules) > 1:
raise CantCreateSingleRuleException(cls)
right = cls.rules[0][1]
if len(right) > 1:
raise NotASingleSymbolException(right)
return right[0]"
4001,"def _get_fromSymbol(cls):
# type: (_MetaRule) -> object
""""""
Get symbol to which the rule is rewrote.
:param cls: Rule for which return the symbol.
:return: Symbol to which the rule is rewrote.
:raise RuleNotDefinedException: If the rule is not defined.
:raise CantCreateSingleRuleException: If the rule consists of more rules.
:raise NotASingleSymbolException: If number of symbols on the right is more.
""""""
if cls._traverse:
raise RuleNotDefinedException(cls)
if len(cls.rules) > 1:
raise CantCreateSingleRuleException(cls)
left = cls.rules[0][0]
if len(left) > 1:
raise NotASingleSymbolException(left)
return left[0]"
4002,"def _get_right(cls):
# type: (_MetaRule) -> List[object]
""""""
Get right part of the rule.
:param cls: Rule for which return the right side.
:return: Symbols on the right side of the array.
:raise RuleNotDefinedException: If the rule is not defined.
:raise CantCreateSingleRuleException: If the rule consists of more rules.
:raise NotASingleSymbolException: If number of symbols on the left is more.
""""""
if cls._traverse:
return [cls.toSymbol]
if len(cls.rules) > 1:
raise CantCreateSingleRuleException(cls)
return cls.rules[0][1]"
4003,"def _get_left(cls):
# type: (_MetaRule) -> List[object]
""""""
Get left part of the rule.
:param cls: Rule for which return the left side.
:return: Symbols on the left side of the array.
:raise RuleNotDefinedException: If the rule is not defined.
:raise CantCreateSingleRuleException: If the rule consists of more rules.
:raise NotASingleSymbolException: If number of symbols on the left is more.
""""""
if cls._traverse:
return [cls.fromSymbol]