mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Clean code
This commit is contained in:
@ -12,6 +12,9 @@ import os
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
FileExtensions = {
|
||||
'Pages': ('md', 'pug')}
|
||||
|
||||
def ReadFile(p):
|
||||
try:
|
||||
with open(p, 'r') as f:
|
||||
@ -63,6 +66,10 @@ def DashifyStr(s, Limit=32):
|
||||
Str += c
|
||||
return '-' + Str
|
||||
|
||||
def GetPathLevels(Path, AsNum=False, Add=0, Sub=0):
|
||||
n = Path.count('/') + Add - Sub
|
||||
return n if AsNum else '../' * n
|
||||
|
||||
# https://stackoverflow.com/a/34445090
|
||||
def FindAllIndex(Str, Sub):
|
||||
i = Str.find(Sub)
|
||||
@ -86,6 +93,11 @@ def ReplWithEsc(Str, Find, Repl, Esc='\\'):
|
||||
New += Repl + e
|
||||
return New
|
||||
|
||||
def RevSort(List):
|
||||
List.sort()
|
||||
List.reverse()
|
||||
return List
|
||||
|
||||
def GetFullDate(Date):
|
||||
if not Date:
|
||||
return None
|
||||
|
Reference in New Issue
Block a user