fix note append of under python 2 with unicode
This commit is contained in:
parent
2b408fe7ea
commit
fe014bc0a5
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
### Implemented enhancements
|
### Implemented enhancements
|
||||||
|
|
||||||
|
- Added append functionality to the note command ([#201](https://github.com/pubs/pubs/pull/201) by [DV Klopfenstein](http://github.com/dvklopfenstein))
|
||||||
- New git plugin to commit changes to the repository ([#191](https://github.com/pubs/pubs/pull/191) by [Amlesh Sivanantham](http://github.com/zamlz))
|
- New git plugin to commit changes to the repository ([#191](https://github.com/pubs/pubs/pull/191) by [Amlesh Sivanantham](http://github.com/zamlz))
|
||||||
- The import command now warn, rather than fail on existing citekeys. ([#198](https://github.com/pubs/pubs/pull/198) by [Kyle Sunden](https://github.com/ksunden))
|
- The import command now warn, rather than fail on existing citekeys. ([#198](https://github.com/pubs/pubs/pull/198) by [Kyle Sunden](https://github.com/ksunden))
|
||||||
- Add `citekey` filter to `query` ([#193](https://github.com/pubs/pubs/pull/193) by [Shane Stone](https://github.com/shanewstone))
|
- Add `citekey` filter to `query` ([#193](https://github.com/pubs/pubs/pull/193) by [Shane Stone](https://github.com/shanewstone))
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from .. import p3
|
||||||
from .. import repo
|
from .. import repo
|
||||||
from ..uis import get_ui
|
from ..uis import get_ui
|
||||||
from ..utils import resolve_citekey
|
from ..utils import resolve_citekey
|
||||||
@ -25,7 +28,7 @@ def command(conf, args):
|
|||||||
if args.append is None:
|
if args.append is None:
|
||||||
ui.edit_file(notepath, temporary=False)
|
ui.edit_file(notepath, temporary=False)
|
||||||
else:
|
else:
|
||||||
latestnote = '{txt}\n'.format(txt=args.append)
|
latestnote = '{txt}\n'.format(txt=p3.u_maybe(args.append))
|
||||||
write_file(notepath, latestnote, 'a')
|
write_file(notepath, latestnote, 'a')
|
||||||
NoteEvent(citekey).send()
|
NoteEvent(citekey).send()
|
||||||
rp.close()
|
rp.close()
|
||||||
|
@ -156,3 +156,4 @@ You can access the self-documented configuration by using `pubs conf`, and all t
|
|||||||
- [Kyle Sunden](https://github.com/ksunden)
|
- [Kyle Sunden](https://github.com/ksunden)
|
||||||
- [Shane Stone](https://github.com/shanewstone)
|
- [Shane Stone](https://github.com/shanewstone)
|
||||||
- [Amlesh Sivanantham](http://github.com/zamlz)
|
- [Amlesh Sivanantham](http://github.com/zamlz)
|
||||||
|
- [DV Klopfenstein](http://github.com/dvklopfenstein)
|
||||||
|
@ -3,6 +3,7 @@ import io
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
|
import locale
|
||||||
|
|
||||||
import dotdot
|
import dotdot
|
||||||
|
|
||||||
@ -23,6 +24,11 @@ real_io = io
|
|||||||
original_exception_handler = uis.InputUI.handle_exception
|
original_exception_handler = uis.InputUI.handle_exception
|
||||||
|
|
||||||
|
|
||||||
|
# needed to get locale.getpreferredencoding(False) (invoked by pyfakefs)
|
||||||
|
# to work properly
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
|
|
||||||
# capture output
|
# capture output
|
||||||
|
|
||||||
def capture(f, verbose=False):
|
def capture(f, verbose=False):
|
||||||
|
@ -45,23 +45,24 @@ class TestNoteAppend(DataCommandTestCase):
|
|||||||
# Test multiword line.
|
# Test multiword line.
|
||||||
# * Pass the command split into a command and its args to
|
# * Pass the command split into a command and its args to
|
||||||
# execute_cmdsplit, which is called by execute_cmds:
|
# execute_cmdsplit, which is called by execute_cmds:
|
||||||
#cmds = [('pubs note Page99 -a "xxx yyy"')]
|
|
||||||
cmd_split = ['pubs', 'note', 'Page99', '-a', 'xxx yyy']
|
cmd_split = ['pubs', 'note', 'Page99', '-a', 'xxx yyy']
|
||||||
self.execute_cmdsplit(cmd_split, expected_out=None, expected_err=None)
|
self.execute_cmdsplit(cmd_split, expected_out=None, expected_err=None)
|
||||||
note_lines.append('xxx yyy')
|
note_lines.append('xxx yyy')
|
||||||
self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
||||||
|
|
||||||
# # https://github.com/pubs/pubs/pull/201#discussion_r305274071
|
def test_note_append_unicode(self):
|
||||||
# # Test adding Chinese characters
|
fin_notes = os.path.join(self.note_dir, 'Page99.txt')
|
||||||
# cmds = [('pubs note Page99 -a \347\350\346\345')]
|
# https://github.com/pubs/pubs/pull/201#discussion_r305274071
|
||||||
# self.execute_cmds(cmds)
|
# Test adding Chinese characters
|
||||||
# note_lines.append('\347\350\346\345')
|
cmds = [('pubs note Page99 -a \347\350\346\345')]
|
||||||
# self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
self.execute_cmds(cmds)
|
||||||
# # Test adding Japanese character
|
note_lines = ['\347\350\346\345']
|
||||||
# cmds = [('pubs note Page99 -a ソ')]
|
self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
||||||
# self.execute_cmds(cmds)
|
# Test adding Japanese character
|
||||||
# note_lines.append('ソ')
|
cmds = [('pubs note Page99 -a ソ')]
|
||||||
# self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
self.execute_cmds(cmds)
|
||||||
|
note_lines.append('ソ')
|
||||||
|
self.assertFileContentEqual(fin_notes, self._get_note_content(note_lines))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_note_content(note_lines):
|
def _get_note_content(note_lines):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user