Author: bugman Date: Tue Jan 21 10:32:48 2014 New Revision: 22036 URL: http://svn.gna.org/viewcvs/relax?rev=22036&view=rev Log: Merged revisions 22032 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r22032 | bugman | 2014-01-21 10:23:35 +0100 (Tue, 21 Jan 2014) | 6 lines The structure.write_pdb user function can now handle a file instance for the file argument. This is for the Structure.test_bug_21522_master_record_atom_count system test, to allow a dummy file object to be used. This can also be useful for power users. ........ Modified: branches/double_rotor/ (props changed) branches/double_rotor/pipe_control/structure/main.py branches/double_rotor/user_functions/structure.py Propchange: branches/double_rotor/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Jan 21 10:32:48 2014 @@ -1,1 +1,1 @@ -/trunk:1-22029,22031 +/trunk:1-22029,22031-22032 Modified: branches/double_rotor/pipe_control/structure/main.py URL: http://svn.gna.org/viewcvs/relax/branches/double_rotor/pipe_control/structure/main.py?rev=22036&r1=22035&r2=22036&view=diff ============================================================================== --- branches/double_rotor/pipe_control/structure/main.py (original) +++ branches/double_rotor/pipe_control/structure/main.py Tue Jan 21 10:32:48 2014 @@ -1179,8 +1179,8 @@ def write_pdb(file=None, dir=None, model_num=None, compress_type=0, force=False): """The PDB writing function. - @keyword file: The name of the PDB file to write. - @type file: str + @keyword file: The name of the PDB file to write. This can also be a file instance. + @type file: str or file instance @keyword dir: The directory where the PDB file will be placed. If set to None, then the file will be placed in the current directory. @type dir: str or None @keyword model_num: The model to place into the PDB file. If not supplied, then all models will be placed into the file. @@ -1198,15 +1198,17 @@ if not hasattr(cdp, 'structure'): raise RelaxError("No structural data is present in the current data pipe.") - # The file path. - file_path = get_file_path(file, dir) - - # Add '.pdb' to the end of the file path if it isn't there yet. - if not search(".pdb$", file_path): - file_path = file_path + '.pdb' + # Path handling. + if isinstance(file, str): + # The file path. + file = get_file_path(file, dir) + + # Add '.pdb' to the end of the file path if it isn't there yet. + if not search(".pdb$", file): + file = file + '.pdb' # Open the file for writing. - file = open_write_file(file_path, compress_type=compress_type, force=force) + file = open_write_file(file, compress_type=compress_type, force=force) # Write the structures. cdp.structure.write_pdb(file, model_num=model_num) Modified: branches/double_rotor/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/double_rotor/user_functions/structure.py?rev=22036&r1=22035&r2=22036&view=diff ============================================================================== --- branches/double_rotor/user_functions/structure.py (original) +++ branches/double_rotor/user_functions/structure.py Tue Jan 21 10:32:48 2014 @@ -1058,7 +1058,7 @@ uf.title_short = "PDB writing." uf.add_keyarg( name = "file", - py_type = "str", + py_type = "str_or_inst", arg_type = "file sel", desc_short = "file name", desc = "The name of the PDB file.",