Merge pull request #204 from chrissexton/parallel_edits

Allow parallel edits
This commit is contained in:
Manuel Ebert 2014-06-26 15:19:38 +02:00
commit 0a59dc198d
2 changed files with 12 additions and 12 deletions

View file

@ -159,17 +159,6 @@ def run(manual_args=None):
touch_journal(config['journal']) touch_journal(config['journal'])
mode_compose, mode_export = guess_mode(args, config) mode_compose, mode_export = guess_mode(args, config)
# open journal file or folder
if os.path.isdir(config['journal']):
if config['journal'].strip("/").endswith(".dayone") or \
"entries" in os.listdir(config['journal']):
journal = DayOneJournal.DayOne(**config)
else:
util.prompt(u"[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
sys.exit(1)
else:
journal = Journal.Journal(journal_name, **config)
# How to quit writing? # How to quit writing?
if "win32" in sys.platform: if "win32" in sys.platform:
_exit_multiline_code = "on a blank line, press Ctrl+Z and then Enter" _exit_multiline_code = "on a blank line, press Ctrl+Z and then Enter"
@ -189,6 +178,17 @@ def run(manual_args=None):
else: else:
mode_compose = False mode_compose = False
# open journal file or folder
if os.path.isdir(config['journal']):
if config['journal'].strip("/").endswith(".dayone") or \
"entries" in os.listdir(config['journal']):
journal = DayOneJournal.DayOne(**config)
else:
util.prompt(u"[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
sys.exit(1)
else:
journal = Journal.Journal(journal_name, **config)
# Writing mode # Writing mode
if mode_compose: if mode_compose:
raw = " ".join(args.text).strip() raw = " ".join(args.text).strip()

View file

@ -114,7 +114,7 @@ def load_and_fix_json(json_path):
sys.exit(1) sys.exit(1)
def get_text_from_editor(config, template=""): def get_text_from_editor(config, template=""):
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl") tmpfile = os.path.join(tempfile.mktemp(prefix="jrnl"))
with codecs.open(tmpfile, 'w', "utf-8") as f: with codecs.open(tmpfile, 'w', "utf-8") as f:
if template: if template:
f.write(template) f.write(template)