Repository: pimutils/khal
Pull request #567 (2017-02-06 17:19:25)

Remove superfluous space from tox.ini
This space made environment generation bugging (leading space), and running `tox` (with no env specified) failed (due to a path being generated with the leading space in it).

untitaker: Hmm, that might be a bug in tox. At least I can't believe this is expected behavior.
hobarrera: Probably, though I don't think they'd support envs with spaces.
geier: thanks

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 3d076fa..5280490 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -19,6 +19,7 @@ not released yet
 * FIX display search results for events with neither DTEND nor DURATION
 * FIX display search results that are all-day events
 * in ikhal, update the date-titles on date change
+* FIX printing a new event's path if [default] print_new = path
 
 0.9.1
 =====
diff --git a/khal/controllers.py b/khal/controllers.py
index c06fe75..1dfaf36 100644
--- a/khal/controllers.py
+++ b/khal/controllers.py
@@ -33,6 +33,7 @@ from shutil import get_terminal_size
 
 from datetime import timedelta, datetime
 import logging
+import os
 import sys
 import textwrap
 
@@ -365,7 +366,10 @@ def new_from_args(collection, calendar_name, conf, dtstart=None, dtend=None,
             format = conf['view']['event_format']
         echo(event.format(format, datetime.now(), env=env))
     elif conf['default']['print_new'] == 'path':
-        path = collection._calnames[event.calendar].path + event.href
+        path = os.path.join(
+            collection._calendars[event.calendar]['path'],
+            event.href
+        )
         echo(path)
     return event
 
diff --git a/setup.py b/setup.py
index 5e961ca..ffddc4d 100755
--- a/setup.py
+++ b/setup.py
@@ -32,9 +32,9 @@ extra_requirements = {
 
 setup(
     name='khal',
-    description='A CalDAV based calendar',
+    description='A standards based terminal calendar',
     long_description=open('README.rst').read(),
-    author='Christian Geier',
+    author='Christian Geier et. al.',
     author_email='khal@lostpackets.de',
     url='http://lostpackets.de/khal/',
     license='Expat/MIT',
@@ -46,7 +46,7 @@ setup(
     entry_points={
         'console_scripts': [
             'khal = khal.cli:main_khal',
-            'ikhal = khal.cli:main_ikhal'
+            'ikhal = khal.cli:main_ikhal',
         ]
     },
     install_requires=requirements,
diff --git a/tox.ini b/tox.ini
index fdf4a6a..b853f35 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = {py33, py34, py35, py36}-{tests, tests-negtz, style}
+envlist = {py33,py34,py35,py36}-{tests,tests-negtz,style}
 skip_missing_interpreters = True
 
 [testenv]


Test patch:
diff --git a/tests/cli_test.py b/tests/cli_test.py
index 030dacc..ee22ba0 100644
--- a/tests/cli_test.py
+++ b/tests/cli_test.py
@@ -45,7 +45,8 @@ def runner(tmpdir, monkeypatch):
     monkeypatch.setattr('xdg.BaseDirectory.xdg_config_home', str(xdg_config_home))
     monkeypatch.setattr('xdg.BaseDirectory.xdg_config_dirs', [str(xdg_config_home)])
 
-    def inner(default_command='list', default_calendar=True, days=2, **kwargs):
+    def inner(default_command='list', print_new=False, default_calendar=True, days=2,
+              **kwargs):
         if default_calendar:
             default_calendar = 'default_calendar = one'
         else:
@@ -54,9 +55,10 @@ def runner(tmpdir, monkeypatch):
             os.makedirs(str(xdg_config_home.join('khal')))
         config_file.write(config_template.format(
             default_command=default_command,
-            delta=str(days)+'d',
+            delta=str(days) + 'd',
             calpath=str(calendar), calpath2=str(calendar2), calpath3=str(calendar3),
             default_calendar=default_calendar,
+            print_new=print_new,
             dbpath=str(db), **kwargs))
         runner = CustomCliRunner(
             config_file=config_file, db=db, calendars=dict(one=calendar),
@@ -94,6 +96,7 @@ firstweekday = 0
 default_command = {default_command}
 {default_calendar}
 timedelta = {delta}
+print_new = {print_new}
 
 [sqlite]
 path = {dbpath}
@@ -667,3 +670,12 @@ def test_edit(runner):
     args = ['list', '--format', format, '--day-format', '', '09.04.2014']
     result = runner.invoke(main_khal, args)
     assert result.output == '09:30-10:30: Great Event\n'
+
+
+def test_new(runner):
+    runner = runner(print_new='path')
+
+    result = runner.invoke(main_khal, 'new 13.03.2016 3d Visit'.split())
+    assert not result.exception
+    assert result.output.endswith('.ics\n')
+    assert result.output.startswith('/tmp/')