Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
fd0d883b
Commit
fd0d883b
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
06a3ef00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
models.py
stbi/Lib/site-packages/pip/_internal/utils/models.py
+42
-0
No files found.
stbi/Lib/site-packages/pip/_internal/utils/models.py
0 → 100644
View file @
fd0d883b
"""Utilities for defining models
"""
# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False
import
operator
class
KeyBasedCompareMixin
(
object
):
"""Provides comparison capabilities that is based on a key
"""
def
__init__
(
self
,
key
,
defining_class
):
self
.
_compare_key
=
key
self
.
_defining_class
=
defining_class
def
__hash__
(
self
):
return
hash
(
self
.
_compare_key
)
def
__lt__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__lt__
)
def
__le__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__le__
)
def
__gt__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__gt__
)
def
__ge__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__ge__
)
def
__eq__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__eq__
)
def
__ne__
(
self
,
other
):
return
self
.
_compare
(
other
,
operator
.
__ne__
)
def
_compare
(
self
,
other
,
method
):
if
not
isinstance
(
other
,
self
.
_defining_class
):
return
NotImplemented
return
method
(
self
.
_compare_key
,
other
.
_compare_key
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment