Ejemplo n.º 1
0
def get_stdin() -> Version:
    """
    Get input from stdin.

    Returns:
        Parsed version.
    """
    if sys.stdin.isatty():
        return Version.zero()

    for line in sys.stdin.readlines():
        return Version(line.strip().split(" ")[-1])

    return Version.zero()
Ejemplo n.º 2
0
def get_stdin() -> Version:
    """
    Get input from stdin.

    Returns:
        Parsed version.
    """
    if sys.stdin.isatty():
        return Version.zero()

    for line in sys.stdin.readlines():
        safe_line = line.strip().split(" ")[-1].replace('"',
                                                        "").replace("'", "")
        return Version(safe_line)

    return Version.zero()
Ejemplo n.º 3
0
    def test_parse(self):
        assert Version.zero().dumps() == "0.0.0"
        assert Version("1.2.3").major == 1
        assert Version("1.2.3").minor == 2
        assert Version("1.2.3").micro == 3
        assert Version("1.2.3").pre == None
        assert Version("1.2.3rc4").pre == ("rc", 4)
        assert Version("1.2.3.alpha4").pre == ("a", 4)
        assert Version("1.2.3.alpha").pre == ("a", 0)
        assert Version("1.2.3-rc4").pre == ("rc", 4)
        assert Version("1.2.3-dev5").is_devrelease
        assert Version("1.2.3").is_stable
        assert not Version("1.2.3").is_devrelease
        assert Version("1.2.3.post3").is_stable
        assert Version("1.2.3.post3").is_postrelease

        with pytest.raises(VersionError):
            Version("invalid")
Ejemplo n.º 4
0
 def __init__(
         self,
         input: Version = Version.zero(),
 ) -> None:
     self._input = input