def add_origin(examples, filename):
 if (not filename):
  return
 vars = (examples.domain.variables + examples.domain.metas)
 strings = [var for var in vars if var.is_string]
 (dir_name, basename) = os.path.split(filename)
 for var in strings:
  if (('type' in var.attributes) and ('origin' not in var.attributes)):
   var.attributes['origin'] = dir_name

def add_origin ( examples , filename ) : if ( not filename ) : return vars = ( examples . domain . variables + examples . domain . metas ) strings = [ var for var in vars if var . is_string ] ( dir_name , basename ) = os . path . split ( filename ) for var in strings : if ( ( 'type' in var . attributes ) and ( 'origin' not in var . attributes ) ) : var . attributes [ 'origin' ] = dir_name
adds attribute with file location to each string variable used for relative filenames stored in string variables todo: we should consider a cleaner solution .