@@ -79,7 +79,7 @@ def mod_read(obj=None, onerrorstop=False, default_owner=None,
7979
8080 if meta_type not in known_types :
8181 if onerrorstop :
82- assert False , "Unsupported type: %s" % meta_type
82+ raise AssertionError ( f "Unsupported type: { meta_type } " )
8383 else :
8484 meta ['unsupported' ] = meta_type
8585 return meta
@@ -139,7 +139,8 @@ def mod_write(data, parent=None, obj_id=None, override=False, root=None,
139139 temp_obj = None
140140 # ID exists? Check for type
141141 if obj and obj .meta_type != meta_type :
142- assert override , "Type mismatch for object " + repr (data )
142+ if not override :
143+ raise AssertionError (f"Type mismatch for object { data !r} " )
143144 contents = obj_contents (obj )
144145 if contents :
145146 # Rename so we can cut+paste the children
@@ -322,10 +323,11 @@ def start_transaction(self, note=''):
322323 # Log in as a manager
323324 uf = self .app .acl_users
324325 user = uf .getUser (self .manager_user ).__of__ (uf )
325- assert user is not None , (
326- 'User %s is not available in database. Perhaps you need to set'
327- ' create_manager_user in config.py?' % self .manager_user
328- )
326+ if user is None :
327+ raise AssertionError (
328+ f'User { self .manager_user } is not available in database.'
329+ ' Perhaps you need to set create_manager_user in config.py?'
330+ )
329331
330332 self .logger .info ('Using user %s' % self .manager_user )
331333 AccessControl .SecurityManagement .newSecurityManager (None , user )
@@ -424,7 +426,8 @@ def fs_pathinfo(self, path):
424426 'layeridx' : None ,
425427 }
426428 path = path .lstrip ('/' )
427- children = set ()
429+ candidates = set () # subfolders on any layer
430+ children = set () # those with a __meta__ file on a some layer
428431 for idx , layer in enumerate (layers ):
429432 fspath = os .path .join (layer ['workdir' ], self .site , path )
430433 if not os .path .isdir (fspath ):
@@ -437,8 +440,14 @@ def fs_pathinfo(self, path):
437440 for entry in os .listdir (fspath ):
438441 if entry in children or entry .startswith ('__' ):
439442 continue
443+ candidates .add (entry )
440444 if os .path .exists (os .path .join (fspath , entry , '__meta__' )):
441445 children .add (entry )
446+ missing = candidates - children
447+ if missing :
448+ raise AssertionError (
449+ f"No __meta__ file on any layer: { path } /{ children } "
450+ )
442451
443452 result ['children' ] = sorted (children )
444453 return result
@@ -632,11 +641,13 @@ def fs_parse(self, fspath, data=None):
632641 if data is None :
633642 data = self .fs_read (fspath )
634643
635- assert 'meta' in data , 'Missing meta file: ' + fspath
644+ if 'meta' not in data :
645+ raise AssertionError (f"Missing meta file: { fspath } " )
636646 src_fnames = data .get ('src_fnames' , [])
637- assert len (src_fnames ) <= 1 , (
638- "Multiple source files in " + fspath
639- )
647+ if len (src_fnames ) > 1 :
648+ raise AssertionError (
649+ f"Multiple source files in { fspath } "
650+ )
640651 result = dict (literal_eval (data ['meta' ]))
641652 if src_fnames :
642653 src_fname = src_fnames [0 ]
0 commit comments