@@ -106,7 +106,7 @@ def make_calendar(
106106 name : Optional [str ] = None ,
107107 cal_id : Optional [str ] = None ,
108108 supported_calendar_component_set : Optional [Any ] = None ,
109- method = None
109+ method = None ,
110110 ) -> "Calendar" :
111111 """
112112 Utility method for creating a new calendar.
@@ -246,7 +246,7 @@ def make_calendar(
246246 name : Optional [str ] = None ,
247247 cal_id : Optional [str ] = None ,
248248 supported_calendar_component_set : Optional [Any ] = None ,
249- method = None
249+ method = None ,
250250 ) -> "Calendar" :
251251 """
252252 Convenience method, bypasses the self.calendar_home_set object.
@@ -256,7 +256,7 @@ def make_calendar(
256256 name ,
257257 cal_id ,
258258 supported_calendar_component_set = supported_calendar_component_set ,
259- method = method
259+ method = method ,
260260 )
261261
262262 def calendar (
@@ -408,7 +408,7 @@ class Calendar(DAVObject):
408408 """
409409
410410 def _create (
411- self , name = None , id = None , supported_calendar_component_set = None , method = None
411+ self , name = None , id = None , supported_calendar_component_set = None , method = None
412412 ) -> None :
413413 """
414414 Create a new calendar with display name `name` in `parent`.
@@ -419,15 +419,22 @@ def _create(
419419
420420 if method is None :
421421 if self .client :
422- supported = self .client .features .check_support ('create-calendar' , return_type = dict )
423- if supported ['support' ] not in ('full' , 'fragile' , 'quirk' ):
424- raise error .MkcalendarError ("Creation of calendars (allegedly) not supported on this server" )
425- if supported ['support' ] == 'quirk' and supported ['behaviour' ] == 'mkcol-required' :
426- method = 'mkcol'
422+ supported = self .client .features .check_support (
423+ "create-calendar" , return_type = dict
424+ )
425+ if supported ["support" ] not in ("full" , "fragile" , "quirk" ):
426+ raise error .MkcalendarError (
427+ "Creation of calendars (allegedly) not supported on this server"
428+ )
429+ if (
430+ supported ["support" ] == "quirk"
431+ and supported ["behaviour" ] == "mkcol-required"
432+ ):
433+ method = "mkcol"
427434 else :
428- method = ' mkcalendar'
435+ method = " mkcalendar"
429436 else :
430- method = ' mkcalendar'
437+ method = " mkcalendar"
431438
432439 path = self .parent .url .join (id + "/" )
433440 self .url = path
@@ -447,13 +454,14 @@ def _create(
447454 for scc in supported_calendar_component_set :
448455 sccs += cdav .Comp (scc )
449456 prop += sccs
450- if method == ' mkcol' :
457+ if method == " mkcol" :
451458 from caldav .lib .debug import printxml
459+
452460 prop += dav .ResourceType () + [dav .Collection (), cdav .Calendar ()]
453461
454462 set = dav .Set () + prop
455463
456- mkcol = (dav .Mkcol () if method == ' mkcol' else cdav .Mkcalendar ()) + set
464+ mkcol = (dav .Mkcol () if method == " mkcol" else cdav .Mkcalendar ()) + set
457465
458466 r = self ._query (
459467 root = mkcol , query_method = method , url = path , expected_return_value = 201
@@ -594,7 +602,7 @@ def save_journal(self, *largs, **kwargs) -> "Journal":
594602 add_todo = save_todo
595603 add_journal = save_journal
596604
597- def save (self , method = None ):
605+ def save (self , method = None ):
598606 """
599607 The save method for a calendar is only used to create it, for now.
600608 We know we have to create it when we don't have a url.
@@ -603,7 +611,9 @@ def save(self, method = None):
603611 * self
604612 """
605613 if self .url is None :
606- self ._create (id = self .id , name = self .name , method = method , ** self .extra_init_options )
614+ self ._create (
615+ id = self .id , name = self .name , method = method , ** self .extra_init_options
616+ )
607617 return self
608618
609619 # def data2object_class
0 commit comments