_basename to basename, since it's not private in use

This commit is contained in:
Arthur Milchior 2020-04-06 23:05:27 +02:00
parent 5315b717c0
commit bda2935de1
3 changed files with 9 additions and 7 deletions

View File

@ -126,7 +126,7 @@ class DeckManager:
# child of an existing deck then it needs to be renamed
deck = self.get(did)
if "::" in deck["name"]:
base = self._basename(deck["name"])
base = self.basename(deck["name"])
suffix = ""
while True:
# find an unused name
@ -261,14 +261,14 @@ class DeckManager:
if ontoDeckDid is None or ontoDeckDid == "":
if len(self.path(draggedDeckName)) > 1:
self.rename(draggedDeck, self._basename(draggedDeckName))
self.rename(draggedDeck, self.basename(draggedDeckName))
elif self._canDragAndDrop(draggedDeckName, ontoDeckName):
draggedDeck = self.get(draggedDeckDid)
draggedDeckName = draggedDeck["name"]
ontoDeckName = self.get(ontoDeckDid)["name"]
assert ontoDeckName.strip()
self.rename(
draggedDeck, ontoDeckName + "::" + self._basename(draggedDeckName)
draggedDeck, ontoDeckName + "::" + self.basename(draggedDeckName)
)
def _canDragAndDrop(self, draggedDeckName: str, ontoDeckName: str) -> bool:
@ -283,7 +283,7 @@ class DeckManager:
def _isParent(self, parentDeckName: str, childDeckName: str) -> Any:
return self.path(childDeckName) == self.path(parentDeckName) + [
self._basename(childDeckName)
self.basename(childDeckName)
]
def _isAncestor(self, ancestorDeckName: str, descendantDeckName: str) -> Any:
@ -297,9 +297,11 @@ class DeckManager:
_path = path
@classmethod
def _basename(cls, name: str) -> Any:
def basename(cls, name: str) -> Any:
return cls.path(name)[-1]
_basename = basename
@classmethod
def key(cls, deck: Dict[str, Any]) -> List[str]:
return cls.path(deck["name"])

View File

@ -154,7 +154,7 @@ def fields_for_rendering(
fields["Tags"] = note.stringTags().strip()
fields["Type"] = card.note_type()["name"]
fields["Deck"] = col.decks.name(card.odid or card.did)
fields["Subdeck"] = DeckManager._basename(fields["Deck"])
fields["Subdeck"] = DeckManager.basename(fields["Deck"])
fields["Card"] = card.template()["name"]
flag = card.userFlag()
fields["CardFlag"] = flag and f"flag{flag}" or ""

View File

@ -1303,7 +1303,7 @@ QTableView {{ gridline-color: {grid} }}
def addDecks(parent, decks):
for head, did, rev, lrn, new, children in decks:
name = self.mw.col.decks.get(did)["name"]
shortname = DeckManager._basename(name)
shortname = DeckManager.basename(name)
if children:
subm = parent.addMenu(shortname)
subm.addItem(_("Filter"), self._filterFunc("deck", name))