def is_safe_filesystem_path_component(path):
 return (path and (not os.path.splitdrive(path)[0]) and (not os.path.split(path)[0]) and (path not in (os.curdir, os.pardir)) and (not path.startswith('.')) and (not path.endswith('~')))

def is_safe_filesystem_path_component ( path ) : return ( path and ( not os . path . splitdrive ( path ) [ 0 ] ) and ( not os . path . split ( path ) [ 0 ] ) and ( path not in ( os . curdir , os . pardir ) ) and ( not path . startswith ( '.' ) ) and ( not path . endswith ( '~' ) ) )
check if path is a single component of a filesystem path .