Merge branch 'master' of lel/AV-98 into master

This commit is contained in:
solderpunk 2019-10-06 10:36:07 -04:00 committed by Gitea
commit 9e6fecc0d8
1 changed files with 4 additions and 7 deletions

11
av98.py
View File

@ -110,13 +110,10 @@ class GeminiItem():
return GeminiItem(self._derive_url("/"))
def up(self):
pathbits = list(os.path.split(self.path))
# Get rid of empty string from trailing /
while not pathbits[-1]:
pathbits.pop()
pathbits = list(os.path.split(self.path.rstrip('/')))
# Don't try to go higher than root
if len(pathbits) == 1:
return self.url
return self
# Get rid of bottom component
pathbits.pop()
new_path = os.path.join(*pathbits)
@ -153,9 +150,9 @@ class GeminiItem():
def to_map_line(self, name=None):
if name or self.name:
return "=> {} {}".format(self.url, name or self.name)
return "=> {} {}\n".format(self.url, name or self.name)
else:
return "=> {}".format(self.url)
return "=> {}\n".format(self.url)
@classmethod
def from_map_line(cls, line, origin_gi):