def check_include_exclude(path_str, include_pat=None, exclude_pat=None):
 ret = True
 if include_pat:
  if re.match('E@', include_pat):
   retchk_include = (True if re.search(include_pat[2:], path_str) else False)
  else:
   retchk_include = (True if fnmatch.fnmatch(path_str, include_pat) else False)
 if exclude_pat:
  if re.match('E@', exclude_pat):
   retchk_exclude = (False if re.search(exclude_pat[2:], path_str) else True)
  else:
   retchk_exclude = (False if fnmatch.fnmatch(path_str, exclude_pat) else True)
 if (include_pat and (not exclude_pat)):
  ret = retchk_include
 elif (exclude_pat and (not include_pat)):
  ret = retchk_exclude
 elif (include_pat and exclude_pat):
  ret = (retchk_include and retchk_exclude)
 else:
  ret = True
 return ret

def check_include_exclude ( path_str , include_pat = None , exclude_pat = None ) : ret = True if include_pat : if re . match ( 'E@' , include_pat ) : retchk_include = ( True if re . search ( include_pat [ 2 : ] , path_str ) else False ) else : retchk_include = ( True if fnmatch . fnmatch ( path_str , include_pat ) else False ) if exclude_pat : if re . match ( 'E@' , exclude_pat ) : retchk_exclude = ( False if re . search ( exclude_pat [ 2 : ] , path_str ) else True ) else : retchk_exclude = ( False if fnmatch . fnmatch ( path_str , exclude_pat ) else True ) if ( include_pat and ( not exclude_pat ) ) : ret = retchk_include elif ( exclude_pat and ( not include_pat ) ) : ret = retchk_exclude elif ( include_pat and exclude_pat ) : ret = ( retchk_include and retchk_exclude ) else : ret = True return ret
check for glob or regexp patterns for include_pat and exclude_pat in the path_str string and return true/false conditions as follows .