@@ -605,17 +605,23 @@ def invalidate_cache(self, path=None):
605605
606606 async def _mkdir (
607607 self ,
608- bucket ,
608+ path ,
609609 acl = "projectPrivate" ,
610610 default_acl = "bucketOwnerFullControl" ,
611611 location = None ,
612+ create_parents = True ,
613+ ** kwargs ,
612614 ):
613615 """
614616 New bucket
615617
618+ If path is more than just a bucket, will create bucket if create_parents=True;
619+ otherwise is a noop. If create_parents is False and bucket does not exist,
620+ will produce FileNotFFoundError.
621+
616622 Parameters
617623 ----------
618- bucket : str
624+ path : str
619625 bucket name. If contains '/' (i.e., looks like subdir), will
620626 have no effect because GCS doesn't have real directories.
621627 acl: string, one of bACLs
@@ -627,11 +633,18 @@ async def _mkdir(
627633 If not provided, defaults to `self.default_location`.
628634 You can find a list of all available locations here:
629635 https://cloud.google.com/storage/docs/locations#available-locations
636+ create_parents: bool
637+ If True, creates the bucket in question, if it doesn't already exist
630638 """
639+ bucket , object = self .split_path (path )
631640 if bucket in ["" , "/" ]:
632641 raise ValueError ("Cannot create root bucket" )
633- if "/" in bucket :
642+ if "/" in path and create_parents and await self ._exists (bucket ):
643+ # nothing to do
634644 return
645+ if "/" in path and not create_parents and not await self ._exists (bucket ):
646+ raise FileNotFoundError (bucket )
647+
635648 json_data = {"name" : bucket }
636649 location = location or self .default_location
637650 if location :
@@ -758,7 +771,7 @@ def url(self, path):
758771 object = quote_plus (object )
759772 return u .format (self ._location , bucket , object )
760773
761- async def _cat_file (self , path , start = None , end = None ):
774+ async def _cat_file (self , path , start = None , end = None , ** kwargs ):
762775 """Simple one-shot get of file data"""
763776 u2 = self .url (path )
764777 if start or end :
0 commit comments