forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify Index._dir_* with Series implementation (pandas-dev#17117)
- Loading branch information
1 parent
c523bfc
commit 5a6f2ac
Showing
6 changed files
with
53 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
accessor.py contains base classes for implementing accessor properties | ||
that can be mixed into or pinned onto other pandas classes. | ||
""" | ||
|
||
|
||
class DirNamesMixin(object): | ||
_accessors = frozenset([]) | ||
|
||
def _dir_deletions(self): | ||
""" delete unwanted __dir__ for this object """ | ||
return self._accessors | ||
|
||
def _dir_additions(self): | ||
""" add addtional __dir__ for this object """ | ||
rv = set() | ||
for accessor in self._accessors: | ||
try: | ||
getattr(self, accessor) | ||
rv.add(accessor) | ||
except AttributeError: | ||
pass | ||
return rv | ||
|
||
def __dir__(self): | ||
""" | ||
Provide method name lookup and completion | ||
Only provide 'public' methods | ||
""" | ||
rv = set(dir(type(self))) | ||
rv = (rv - self._dir_deletions()) | self._dir_additions() | ||
return sorted(rv) |
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
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