コード例 #1
0
	def test_compress_to_tgz(self):
		#test compressing a single file
		filename = get_tmp_filename(tmp_dir=self.tmp_dir)
		f = open(filename, 'w')
		f.close()

		output_tgz = get_tmp_filename(tmp_dir=self.tmp_dir, suffix='.tgz')

		self._paths_to_clean_up = [filename, output_tgz]

		compress_to_tgz(filename, output_tgz)
		self.assertTrue(path.exists(output_tgz), 'The tgz file was not created in the appropiate location')

		#test compressing a directory
		dirname = get_tmp_filename(tmp_dir=self.tmp_dir)
		mkdir(dirname)
		fileA = get_tmp_filename(tmp_dir=dirname)
		f = open(fileA, 'w')
		f.close()
		fileB = get_tmp_filename(tmp_dir=dirname)
		f = open(fileB, 'w')
		f.close()

		output_tgz = get_tmp_filename(tmp_dir=self.tmp_dir, suffix='.tgz')
		
		self._paths_to_clean_up.append(output_tgz)
		self._dirs_to_clean_up = [dirname]

		compress_to_tgz(dirname, output_tgz)
		self.assertTrue(path.exists(output_tgz), 'The tgz file was not created in the appropiate location')
コード例 #2
0
ファイル: compress_path.py プロジェクト: cleme/qiime-galaxy
__license__ = "GPL"
__version__ = "1.4.0-dev"
__maintainer__ = "Jose Antonio Navas Molina"
__email__ = "*****@*****.**"
__status__ = "Development"

from cogent.util.option_parsing import parse_command_line_parameters, make_option
from tgz_manager import compress_to_tgz

script_info = {}
script_info['brief_description'] = "Generate a tgz file which contains the desired path compressed"
script_info['script_description'] = """If input_path is a file: generate a tgz file with the input file compressed.
If input_path is a directory: generate a tgz file with the content of the input directory compressed."""
script_info['script_usage'] = [("Example:", "Generate a tgz file named 'out.tgz' which contains the content of the directory 'in_dir'", "%prog -i in_dir -o out.tgz")]
script_info['output_description'] = ""
script_info['required_options'] = [
	make_option('-i', '--input_path', type="existing_path",
				help='Path to the directory or file to compress'),
	make_option('-o', '--output_tgz', type="new_filepath",
				help='File path of the output tgz file')
]
script_info['optional_options'] = []
script_info['version'] = __version__

if __name__ == '__main__':
	option_parser, opts, args = parse_command_line_parameters(**script_info)
	input_path = opts.input_path
	tgz_fp = opts.output_tgz

	compress_to_tgz(input_path, tgz_fp)