From 65055081f8349e05086af45f270c9e8f34cc2423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20M=C3=A9liani?= <m.meliani@neogeo-online.net> Date: Tue, 22 Oct 2013 13:45:50 +0200 Subject: [PATCH] Mere restructuring... --- src/server.py | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/server.py b/src/server.py index 2027e98..d971ddf 100755 --- a/src/server.py +++ b/src/server.py @@ -71,41 +71,6 @@ class index(object): "fonts": href("fonts"), } -class fonts(object): - """Configure available fonts. - - http://hostname/mra/fonts - - """ - @HTTPCompatible() - def GET(self, format): - """Returns the list of available fonts.""" - - return {"fonts": [f_name - for f_name in mra.list_fontset()]} - - @HTTPCompatible() - def PUT(self, format): - """Uploads fonts from a local source.""" - - import zipfile - ctype = web.ctx.env.get("CONTENT_TYPE", None) - if ctype == "application/zip": - path = mra.create_font("archive.zip", data=web.data()) - with zipfile.ZipFile(path, "r") as z: - z.extractall(mra.get_font_path()) - os.remove(path) - - mra.update_fontset() - - # Then updates (the) mapfile(s) only - # if the fontset path is not specified. - # Should it be done here ?... - mf = mra.get_available() - if mf.ms.fontset.filename == None: - mf.ms.setFontSet(mra.get_fontset_path()) - mf.save() - class workspaces(object): """Workspaces container. @@ -762,6 +727,41 @@ class files(object): else: raise webapp.BadRequest(message="configure must be one of 'first', 'none' or 'all'.") +class fonts(object): + """Configure available fonts. + + http://hostname/mra/fonts + + """ + @HTTPCompatible() + def GET(self, format): + """Returns the list of available fonts.""" + + return {"fonts": [f_name + for f_name in mra.list_fontset()]} + + @HTTPCompatible() + def PUT(self, format): + """Uploads fonts from a local source.""" + + import zipfile + ctype = web.ctx.env.get("CONTENT_TYPE", None) + if ctype == "application/zip": + path = mra.create_font("archive.zip", data=web.data()) + with zipfile.ZipFile(path, "r") as z: + z.extractall(mra.get_font_path()) + os.remove(path) + + mra.update_fontset() + + # Then updates (the) mapfile(s) only + # if the fontset path is not specified. + # Should it be done here ?... + mf = mra.get_available() + if mf.ms.fontset.filename == None: + mf.ms.setFontSet(mra.get_fontset_path()) + mf.save() + class styles(object): """SLD styles container. -- GitLab