-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: popcorny <[email protected]>
- Loading branch information
1 parent
5d7699b
commit d52f048
Showing
6 changed files
with
115 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class DbtVersion: | ||
|
||
def __init__(self): | ||
from dbt import version as dbt_version | ||
self.dbt_version = self.parse(dbt_version.__version__) | ||
|
||
@staticmethod | ||
def parse(version: str): | ||
from packaging import version as v | ||
return v.parse(version) | ||
|
||
def as_version(self, other): | ||
from packaging.version import Version | ||
if isinstance(other, Version): | ||
return other | ||
if isinstance(other, str): | ||
return self.parse(other) | ||
return self.parse(str(other)) | ||
|
||
def __ge__(self, other): | ||
return self.dbt_version >= self.as_version(other) | ||
|
||
def __gt__(self, other): | ||
return self.dbt_version > self.as_version(other) | ||
|
||
def __lt__(self, other): | ||
return self.dbt_version < self.as_version(other) | ||
|
||
def __le__(self, other): | ||
return self.dbt_version <= self.as_version(other) | ||
|
||
def __eq__(self, other): | ||
return self.dbt_version.release[:2] == self.as_version(other).release[:2] | ||
|
||
def __str__(self): | ||
return ".".join([str(x) for x in list(self.dbt_version.release)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters