Commit 53eb46d6 authored by Daniel Stan's avatar Daniel Stan

fname doit être un unicode

On ne gère la conversion vers du binaire (utf-8) qu'au dernier
moment.
parent 64e40a0a
......@@ -961,6 +961,7 @@ if __name__ == "__main__":
liste
""")
parser.add_argument('fname', nargs='?', default=None,
type=lambda x: x.decode('utf-8'),
help="Nom du fichier à afficher")
# On parse les options fournies en commandline
......
......@@ -41,6 +41,8 @@ def validate(roles, mode='r'):
def getpath(filename, backup=False):
"""Récupère le chemin du fichier ``filename``"""
assert(isinstance(filename, unicode))
filename = filename.encode('utf-8')
return os.path.join(serverconfig.STORE, '%s.%s' % (filename, 'bak' if backup else 'json'))
def writefile(filename, contents):
......@@ -140,7 +142,8 @@ def listfiles():
files = {}
for filename in filenames:
file_dict = json.loads(open(filename).read())
files[filename[:-5]] = file_dict["roles"]
fname = filename[:-5].decode('utf-8')
files[fname] = file_dict["roles"]
return files
@server_command('getfile')
......
Markdown is supported
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