Skip to content

HACK: update versionstring to parse OS info from PG_VERSION #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build
dist
*.pyc

# JetBrains
.idea
5 changes: 3 additions & 2 deletions postgresql/versionstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
(8, 0, 1, None, None)
"""


def split(vstr: str) -> tuple:
"""
Split a PostgreSQL version string into a tuple.
(major, minor, patch, ..., state_class, state_level)
"""
v = vstr.strip().split('.')
v = vstr.strip().split('(')

# Get rid of the numbers around the state_class (beta,a,dev,alpha, etc)
state_class = v[-1].strip('0123456789')
Expand All @@ -23,7 +24,7 @@ def split(vstr: str) -> tuple:
state_level = None
else:
state_level = int(state_level)
vlist = [int(x or '0') for x in v[:-1]]
vlist = [int(float(x) or '0') for x in v[:-1]]
if last_version:
vlist.append(int(last_version))
vlist += [None] * (3 - len(vlist))
Expand Down