Commit 0ce1aabb authored by dwoiwode's avatar dwoiwode
Browse files

Add cached option for pads

parent 50bf8f3d
......@@ -364,7 +364,7 @@ class PadCollection(BasePad):
if line.startswith("# "):
current_folder = line.split("#")[1].strip()
continue
pad = self.parse_pad(line)
pad = self.parse_pad(line, cache=False)
if pad is None:
continue
if current_folder not in pads:
......@@ -377,10 +377,15 @@ class PadCollection(BasePad):
pad.folder = current_folder
pads[current_folder].append(pad)
return pads
full_pads = dict()
for folder in pads:
if len(pads[folder]) > 0:
full_pads[folder] = pads[folder]
return full_pads
@classmethod
def parse_pad(cls, line: str, prefixes=None) -> Optional[BasePad]:
def parse_pad(cls, line: str, prefixes=None, cache=True) -> Optional[BasePad]:
url, *comment = line.split("#")
if not url.strip(): # Only whitespace
return None
......@@ -390,9 +395,9 @@ class PadCollection(BasePad):
url = f"https://{url}".strip()
if Etherpad.fit_url(url):
retrieve_class = CachedEtherPad
retrieve_class = CachedEtherPad if cache else Etherpad
elif CodiMD.fit_url(url):
retrieve_class = CachedCodiMD
retrieve_class = CachedCodiMD if cache else CodiMD
else:
raise ValueError("Cannot retrieve SourceType class")
src = retrieve_class(url)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment