Merge branch 'enh-human-readable-date' of https://github.com/kir0ul/yunohost into enh-human-readable-date

This commit is contained in:
ljf 2018-12-09 11:54:13 +01:00
commit 18c156a2c0
2 changed files with 18 additions and 1 deletions

View file

@ -470,6 +470,11 @@ app:
listlists:
action_help: List registered application lists
api: GET /appslists
arguments:
-H:
full: --human-readable
help: Return the lastUpdate with a human readable date
action: store_true
### app_removelist()
removelist:

View file

@ -36,6 +36,7 @@ import glob
import pwd
import grp
from collections import OrderedDict
import datetime
from moulinette import msignals, m18n, msettings
from moulinette.core import MoulinetteError
@ -66,10 +67,13 @@ re_app_instance_name = re.compile(
)
def app_listlists():
def app_listlists(human_readable=False):
"""
List fetched lists
Keyword argument:
human_readable -- Show human readable dates
"""
# Migrate appslist system if needed
@ -80,6 +84,14 @@ def app_listlists():
# Get the list
appslist_list = _read_appslist_list()
# Human readable date
if human_readable:
for app in appslist_list:
now_for_humans = datetime.datetime.fromtimestamp(
appslist_list[app].get("lastUpdate"))
appslist_list[app]["lastUpdate"] = now_for_humans.strftime(
'%Y-%m-%d %H:%M:%S')
return appslist_list