1
1
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yadc/yadc/utils.py

24 lines
755 B
Python

#https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
def sizeof_fmt(num, suffix='B'):
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Yi', suffix)
from flask import request
from werkzeug.urls import Href
def query_replace(dic, base=''):
args = request.args.to_dict()
return Href(base)(args.update(dic) or args)
from flask import request, url_for
from werkzeug.urls import url_parse
def nextpage():
nextpg = request.args.get('next')
if not nextpg or url_parse(nextpg).netloc != '':
nextpg = url_for('main.index')
return nextpg