diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-03-10 00:30:24 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-03-10 00:30:24 +0100 |
commit | fcf18de4a44fcc496837fbb6eedcc01e5f6eb680 (patch) | |
tree | 8f65cdc607c7a41e5789eb3bd04c80ef732f6865 /patches | |
parent | c92933bfa2d95533ea5c8650ff4d40b6621e600f (diff) | |
download | Nix-fcf18de4a44fcc496837fbb6eedcc01e5f6eb680.tar.gz Nix-fcf18de4a44fcc496837fbb6eedcc01e5f6eb680.tar.zst Nix-fcf18de4a44fcc496837fbb6eedcc01e5f6eb680.zip |
Upgrade packages to 19.03
Diffstat (limited to 'patches')
-rw-r--r-- | patches/terminal_velocity_fix_build.patch | 6 | ||||
-rw-r--r-- | patches/terminal_velocity_python3_support.patch | 215 | ||||
-rw-r--r-- | patches/terminal_velocity_sort_found_notes.patch | 16 |
3 files changed, 232 insertions, 5 deletions
diff --git a/patches/terminal_velocity_fix_build.patch b/patches/terminal_velocity_fix_build.patch index 5c7f716..b08e0c4 100644 --- a/patches/terminal_velocity_fix_build.patch +++ b/patches/terminal_velocity_fix_build.patch | |||
@@ -1,3 +1,9 @@ | |||
1 | commit a64bf3d58f6ba7f5fa72fe5b89a3973cac0c1a99 | ||
2 | Author: Ismaël Bouya <ismael.bouya@normalesup.org> | ||
3 | Date: Sat Mar 9 20:13:52 2019 +0100 | ||
4 | |||
5 | Remove mister_bump dependency | ||
6 | |||
1 | diff --git a/setup.py b/setup.py | 7 | diff --git a/setup.py b/setup.py |
2 | index 84a99e9..a783dff 100644 | 8 | index 84a99e9..a783dff 100644 |
3 | --- a/setup.py | 9 | --- a/setup.py |
diff --git a/patches/terminal_velocity_python3_support.patch b/patches/terminal_velocity_python3_support.patch new file mode 100644 index 0000000..bd4aec7 --- /dev/null +++ b/patches/terminal_velocity_python3_support.patch | |||
@@ -0,0 +1,215 @@ | |||
1 | commit 6ca19964b9e8a7866fd7e21a3dac9ccd35f0d434 | ||
2 | Author: Ismaël Bouya <ismael.bouya@normalesup.org> | ||
3 | Date: Sat Mar 9 20:13:18 2019 +0100 | ||
4 | |||
5 | Add python3 support | ||
6 | |||
7 | diff --git a/terminal_velocity/notebook.py b/terminal_velocity/notebook.py | ||
8 | index b6226dc..11f76de 100644 | ||
9 | --- a/terminal_velocity/notebook.py | ||
10 | +++ b/terminal_velocity/notebook.py | ||
11 | @@ -60,51 +60,6 @@ import sys | ||
12 | import chardet | ||
13 | |||
14 | |||
15 | -def unicode_or_bust(raw_text): | ||
16 | - """Return the given raw text data decoded to unicode. | ||
17 | - | ||
18 | - If the text cannot be decoded, return None. | ||
19 | - | ||
20 | - """ | ||
21 | - encodings = ["utf-8"] | ||
22 | - for encoding in (sys.getfilesystemencoding(), sys.getdefaultencoding()): | ||
23 | - # I would use a set for this, but they don't maintain order. | ||
24 | - if encoding not in encodings: | ||
25 | - encodings.append(encoding) | ||
26 | - | ||
27 | - for encoding in encodings: | ||
28 | - if encoding: # getfilesystemencoding() may return None | ||
29 | - try: | ||
30 | - decoded = unicode(raw_text, encoding=encoding) | ||
31 | - return decoded | ||
32 | - except UnicodeDecodeError: | ||
33 | - pass | ||
34 | - | ||
35 | - # If none of those guesses worked, let chardet have a go. | ||
36 | - encoding = chardet.detect(raw_text)["encoding"] | ||
37 | - if encoding and encoding not in encodings: | ||
38 | - try: | ||
39 | - decoded = unicode(raw_text, encoding=encoding) | ||
40 | - logger.debug("File decoded with chardet, encoding was {0}".format( | ||
41 | - encoding)) | ||
42 | - return decoded | ||
43 | - except UnicodeDecodeError: | ||
44 | - pass | ||
45 | - except LookupError: | ||
46 | - pass | ||
47 | - | ||
48 | - # I've heard that decoding with cp1252 never fails, so try that last. | ||
49 | - try: | ||
50 | - decoded = unicode(raw_text, encoding="cp1252") | ||
51 | - logger.debug("File decoded with encoding cp1252") | ||
52 | - return decoded | ||
53 | - except UnicodeDecodeError: | ||
54 | - pass | ||
55 | - | ||
56 | - # If nothing worked then give up. | ||
57 | - return None | ||
58 | - | ||
59 | - | ||
60 | class Error(Exception): | ||
61 | """Base class for exceptions in this module.""" | ||
62 | pass | ||
63 | @@ -192,12 +147,12 @@ class PlainTextNote(object): | ||
64 | # subdirs) if they don't exist. | ||
65 | directory = os.path.split(self.abspath)[0] | ||
66 | if not os.path.isdir(directory): | ||
67 | - logger.debug(u"'{0} doesn't exist, creating it".format(directory)) | ||
68 | + logger.debug("'{0} doesn't exist, creating it".format(directory)) | ||
69 | try: | ||
70 | os.makedirs(directory) | ||
71 | except os.error as e: | ||
72 | raise NewNoteError( | ||
73 | - u"{0} could not be created: {1}".format(directory, e)) | ||
74 | + "{0} could not be created: {1}".format(directory, e)) | ||
75 | |||
76 | # Create an empty file if the file doesn't exist. | ||
77 | open(self.abspath, 'a') | ||
78 | @@ -217,11 +172,11 @@ class PlainTextNote(object): | ||
79 | |||
80 | @property | ||
81 | def contents(self): | ||
82 | - contents = unicode_or_bust(open(self.abspath, "r").read()) | ||
83 | + contents = open(self.abspath, "rb").read().decode(errors='ignore') | ||
84 | if contents is None: | ||
85 | logger.error( | ||
86 | - u"Could not decode file contents: {0}".format(self.abspath)) | ||
87 | - return u"" | ||
88 | + "Could not decode file contents: {0}".format(self.abspath)) | ||
89 | + return "" | ||
90 | else: | ||
91 | return contents | ||
92 | |||
93 | @@ -322,12 +277,12 @@ class PlainTextNoteBook(object): | ||
94 | |||
95 | # Create notebook_dir if it doesn't exist. | ||
96 | if not os.path.isdir(self.path): | ||
97 | - logger.debug(u"'{0} doesn't exist, creating it".format(self.path)) | ||
98 | + logger.debug("'{0} doesn't exist, creating it".format(self.path)) | ||
99 | try: | ||
100 | os.makedirs(self.path) | ||
101 | except os.error as e: | ||
102 | raise NewNoteBookError( | ||
103 | - u"{0} could not be created: {1}".format(self.path, e)) | ||
104 | + "{0} could not be created: {1}".format(self.path, e)) | ||
105 | else: | ||
106 | # TODO: Check that self.path is a directory, if not raise. | ||
107 | pass | ||
108 | @@ -358,13 +313,12 @@ class PlainTextNoteBook(object): | ||
109 | abspath = os.path.join(root, filename) | ||
110 | relpath = os.path.relpath(abspath, self.path) | ||
111 | relpath, ext = os.path.splitext(relpath) | ||
112 | - unicode_relpath = unicode_or_bust(relpath) | ||
113 | if relpath is None: | ||
114 | # The filename could not be decoded. | ||
115 | logger.error( | ||
116 | "Could not decode filename: {0}".format(relpath)) | ||
117 | else: | ||
118 | - self.add_new(title=unicode_relpath, extension=ext) | ||
119 | + self.add_new(title=relpath, extension=ext) | ||
120 | |||
121 | @property | ||
122 | def path(self): | ||
123 | @@ -418,7 +372,7 @@ class PlainTextNoteBook(object): | ||
124 | for note in self._notes: | ||
125 | if note.title == title and note.extension == extension: | ||
126 | raise NoteAlreadyExistsError( | ||
127 | - u"Note already in NoteBook: {0}".format(note.title)) | ||
128 | + "Note already in NoteBook: {0}".format(note.title)) | ||
129 | |||
130 | # Ok, add the note. | ||
131 | note = PlainTextNote(title, self, extension) | ||
132 | diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py | ||
133 | index 5f0e213..9234bea 100755 | ||
134 | --- a/terminal_velocity/terminal_velocity.py | ||
135 | +++ b/terminal_velocity/terminal_velocity.py | ||
136 | @@ -1,7 +1,7 @@ | ||
137 | -#!/usr/bin/env python2 | ||
138 | +#!/usr/bin/env python3 | ||
139 | """A fast note-taking app for the UNIX terminal""" | ||
140 | from __future__ import print_function | ||
141 | -import ConfigParser | ||
142 | +import configparser | ||
143 | import argparse | ||
144 | import os | ||
145 | import logging | ||
146 | @@ -9,9 +9,9 @@ import logging.handlers | ||
147 | import sys | ||
148 | |||
149 | #import terminal_velocity.urwid_ui as urwid_ui | ||
150 | -import urwid_ui | ||
151 | +from . import urwid_ui | ||
152 | |||
153 | -from git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes | ||
154 | +from .git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes | ||
155 | |||
156 | |||
157 | def startup(): | ||
158 | @@ -37,7 +37,7 @@ def main(): | ||
159 | |||
160 | # Parse the config file. | ||
161 | config_file = os.path.abspath(os.path.expanduser(args.config)) | ||
162 | - config = ConfigParser.SafeConfigParser() | ||
163 | + config = configparser.ConfigParser() | ||
164 | config.read(config_file) | ||
165 | defaults = dict(config.items('DEFAULT')) | ||
166 | |||
167 | diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py | ||
168 | index caebcb9..89bab35 100644 | ||
169 | --- a/terminal_velocity/urwid_ui.py | ||
170 | +++ b/terminal_velocity/urwid_ui.py | ||
171 | @@ -10,7 +10,7 @@ import logging | ||
172 | logger = logging.getLogger(__name__) | ||
173 | |||
174 | import urwid | ||
175 | -import notebook | ||
176 | +from . import notebook | ||
177 | |||
178 | |||
179 | palette = [ | ||
180 | @@ -27,8 +27,6 @@ def system(cmd, loop): | ||
181 | |||
182 | loop.screen.stop() | ||
183 | |||
184 | - cmd = u"{0}".format(cmd) | ||
185 | - cmd = cmd.encode("utf-8") # FIXME: Correct encoding? | ||
186 | safe_cmd = shlex.split(cmd) | ||
187 | |||
188 | logger.debug("System command: {0}".format(safe_cmd)) | ||
189 | @@ -114,7 +112,7 @@ class AutocompleteWidget(urwid.Edit): | ||
190 | |||
191 | # When search bar is empty show placeholder text. | ||
192 | if not self.edit_text and not self.autocomplete_text: | ||
193 | - placeholder_text = u"Find or Create" | ||
194 | + placeholder_text = "Find or Create" | ||
195 | return (placeholder_text, | ||
196 | [("placeholder", len(placeholder_text))]) | ||
197 | |||
198 | @@ -186,7 +184,7 @@ class NoteFilterListBox(urwid.ListBox): | ||
199 | |||
200 | def render(self, size, focus=False): | ||
201 | if len(self.list_walker) == 0: | ||
202 | - placeholder = placeholder_text(u"No matching notes, press Enter " | ||
203 | + placeholder = placeholder_text("No matching notes, press Enter " | ||
204 | "to create a new note") | ||
205 | return placeholder.render(size) | ||
206 | return super(NoteFilterListBox, self).render(size, self.fake_focus) | ||
207 | @@ -399,7 +397,7 @@ class MainFrame(urwid.Frame): | ||
208 | # If the user has no notes yet show some placeholder text, otherwise | ||
209 | # show the note list. | ||
210 | if len(self.notebook) == 0: | ||
211 | - self.body = placeholder_text(u"You have no notes yet, to create " | ||
212 | + self.body = placeholder_text("You have no notes yet, to create " | ||
213 | "a note type a note title then press Enter") | ||
214 | else: | ||
215 | self.body = urwid.Padding(self.list_box, left=1, right=1) | ||
diff --git a/patches/terminal_velocity_sort_found_notes.patch b/patches/terminal_velocity_sort_found_notes.patch index 8296d54..2bc563c 100644 --- a/patches/terminal_velocity_sort_found_notes.patch +++ b/patches/terminal_velocity_sort_found_notes.patch | |||
@@ -1,8 +1,14 @@ | |||
1 | commit 0f9df37046e58c8963aff93c649e5d3dbf2202bd | ||
2 | Author: Ismaël Bouya <ismael.bouya@normalesup.org> | ||
3 | Date: Sat Mar 9 20:11:46 2019 +0100 | ||
4 | |||
5 | Add sorting option | ||
6 | |||
1 | diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py | 7 | diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py |
2 | index db2eb05..bb77dc6 100755 | 8 | index a53eda3..5f0e213 100755 |
3 | --- a/terminal_velocity/terminal_velocity.py | 9 | --- a/terminal_velocity/terminal_velocity.py |
4 | +++ b/terminal_velocity/terminal_velocity.py | 10 | +++ b/terminal_velocity/terminal_velocity.py |
5 | @@ -75,6 +75,10 @@ the default default will be used""" | 11 | @@ -90,6 +90,10 @@ the default default will be used""" |
6 | default=defaults.get("log_file", "~/.tvlog"), | 12 | default=defaults.get("log_file", "~/.tvlog"), |
7 | help="the file to log to (default: %(default)s)") | 13 | help="the file to log to (default: %(default)s)") |
8 | 14 | ||
@@ -13,15 +19,15 @@ index db2eb05..bb77dc6 100755 | |||
13 | parser.add_argument("-p", "--print-config", dest="print_config", | 19 | parser.add_argument("-p", "--print-config", dest="print_config", |
14 | action="store_true", default=False, | 20 | action="store_true", default=False, |
15 | help="print your configuration settings then exit") | 21 | help="print your configuration settings then exit") |
16 | @@ -120,7 +124,7 @@ the default default will be used""" | 22 | @@ -138,7 +142,7 @@ the default default will be used""" |
17 | try: | 23 | try: |
18 | urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor, | 24 | urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor, |
19 | extension=args.extension, extensions=args.extensions, | 25 | extension=args.extension, extensions=args.extensions, |
20 | - exclude=args.exclude) | 26 | - exclude=args.exclude) |
21 | + exclude=args.exclude, sort=args.sort) | 27 | + exclude=args.exclude, sort=args.sort) |
22 | except KeyboardInterrupt: | 28 | except KeyboardInterrupt: |
23 | # Silence KeyboardInterrupt tracebacks on ctrl-c. | 29 | # Run the shutdown hook |
24 | sys.exit() | 30 | shutdown() |
25 | diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py | 31 | diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py |
26 | index 34cf4f6..caebcb9 100644 | 32 | index 34cf4f6..caebcb9 100644 |
27 | --- a/terminal_velocity/urwid_ui.py | 33 | --- a/terminal_velocity/urwid_ui.py |