~ubuntu-branches/ubuntu/saucy/click/saucy-proposed

« back to all changes in this revision

Viewing changes to click/commands/desktophook.py

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2013-07-30 15:14:16 UTC
  • Revision ID: package-import@ubuntu.com-20130730151416-ajoe6kqrb59kkamo
Tags: 0.2.10
* Force click's stdout encoding to UTF-8 regardless of the locale.
* Don't encode non-ASCII characters in JSON dumps.
* Treat manifests as UTF-8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from __future__ import print_function
19
19
 
20
20
import errno
 
21
import io
21
22
import json
22
23
from optparse import OptionParser
23
24
import os
36
37
            continue
37
38
        path = os.path.join(directory, entry)
38
39
        if only_ours:
39
 
            with open(path) as f:
 
40
            with io.open(path, encoding="UTF-8") as f:
40
41
                if COMMENT not in f.read():
41
42
                    continue
42
43
        yield entry
70
71
        directory = find_package_directory(path)
71
72
        manifest_path = os.path.join(
72
73
            directory, ".click", "info", "%s.manifest" % package)
73
 
        with open(manifest_path) as manifest:
 
74
        with io.open(manifest_path, encoding="UTF-8") as manifest:
74
75
            return json.load(manifest).get("hooks", {}).get(app_name, {})
75
76
    except Exception:
76
77
        return {}
108
109
# implement proper (de)serialisation.
109
110
def write_desktop_file(target_path, source_path, profile):
110
111
    osextras.ensuredir(os.path.dirname(target_path))
111
 
    with open(source_path) as source, open(target_path, "w") as target:
 
112
    with io.open(source_path, encoding="UTF-8") as source, \
 
113
         io.open(target_path, "w", encoding="UTF-8") as target:
112
114
        source_dir = find_package_directory(source_path)
113
115
        written_comment = False
114
116
        seen_path = False