<s> from __future__ import division <EOL> import os <EOL> import shutil <EOL> import sys <EOL> vistrails_src = None <EOL> if not vistrails_src : <EOL> vistrails_src = os . path . dirname ( <EOL> os . path . dirname ( os . path . dirname ( sys . path [ <NUM_LIT:0> ] ) ) ) <EOL> if vistrails_src not in sys . path : <EOL> sys . path . append ( vistrails_src ) <EOL> import vistrails . db . services . io <EOL> from identifiers import identifier as persistence_pkg , old_identifiers as persistence_old_ids <EOL> persistence_pkg_ids = set ( persistence_old_ids ) <EOL> persistence_pkg_ids . add ( persistence_pkg ) <EOL> def find_files ( filename , version = None ) : <EOL> save_bundle , save_dir = vistrails . db . services . io . open_vistrail_bundle_from_zip_xml ( filename ) <EOL> vistrail = save_bundle . vistrail <EOL> log_fname = vistrail . db_log_filename <EOL> log = vistrails . db . services . io . open_log_from_xml ( log_fname , True ) <EOL> if version : <EOL> if isinstance ( version , basestring ) : <EOL> if version in vistrail . db_tags_name_index : <EOL> version = vistrail . db_tags_name_index [ version ] . db_id <EOL> persistent_module_ids = set ( ) <EOL> for action in vistrail . db_actions : <EOL> for op in action . db_operations : <EOL> if op . db_what == '<STR_LIT>' and ( op . vtType == '<STR_LIT>' or <EOL> op . vtType == '<STR_LIT>' ) : <EOL> module = op . db_data <EOL> if module . db_package in persistence_pkg_ids : <EOL> persistent_module_ids . add ( module . db_id ) <EOL> filenames = { } <EOL> tags = { } <EOL> for workflow_exec in log . db_workflow_execs : <EOL> cur_version = workflow_exec . db_parent_version <EOL> if version is not None and cur_version != version : <EOL> continue <EOL> if cur_version in vistrail . db_tags_id_index : <EOL> tags [ cur_version ] = vistrail . db_tags_id_index [ cur_version ] . db_name <EOL> for module_exec in workflow_exec . db_item_execs : <EOL> if module_exec . db_module_id in persistent_module_ids : <EOL> for annotation in module_exec . db_annotations : <EOL> if annotation . db_key == '<STR_LIT>' : <EOL> if cur_version not in filenames : <EOL> filenames [ cur_version ] = set ( ) <EOL> val = annotation . db_value . upper ( ) <EOL> filenames [ cur_version ] . add ( os . path . join ( val [ : <NUM_LIT:2> ] , <EOL> val [ <NUM_LIT:2> : ] ) ) <EOL> shutil . rmtree ( save_dir ) <EOL> return filenames , tags <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> fname = sys . argv [ <NUM_LIT:1> ] <EOL> version = sys . argv [ <NUM_LIT:2> ] if len ( sys . argv ) > <NUM_LIT:2> else None <EOL> if version : <EOL> try : <EOL> version = int ( version ) <EOL> except ValueError : <EOL> pass <EOL> all_files , tags = find_files ( fname , version ) <EOL> for version , filenames in all_files . iteritems ( ) : <EOL> if version in tags : <EOL> print str ( version ) + '<STR_LIT>' + tags [ version ] + '<STR_LIT>' <EOL> else : <EOL> print str ( version ) + '<STR_LIT::>' <EOL> for fname in filenames : <EOL> print '<STR_LIT:U+0020>' , fname </s>
