commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0acfbcd4235b/ Changeset: 0acfbcd4235b Branch: next-stable User: greg Date: 2013-05-23 17:49:52 Summary: Keep all contents of dependency definition files when re-writing them to include missing toolshed and changeset_revision attributes. Affected #: 3 files diff -r 966fbc93c483970092b677f17886e86060941093 -r 0acfbcd4235b989f81c580c434471f1e657f298a lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -129,18 +129,18 @@ # Move some version of the uploaded file to the load_point within the repository hierarchy. if uploaded_file_filename in [ 'repository_dependencies.xml' ]: # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, full_path ) else: shutil.move( uploaded_file_name, full_path ) elif uploaded_file_filename in [ 'tool_dependencies.xml' ]: # Inspect the contents of the file to see if it defines a complex repository dependency definition whose changeset_revision values # are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, full_path ) else: shutil.move( uploaded_file_name, full_path ) @@ -266,15 +266,15 @@ uploaded_file_name = os.path.abspath( os.path.join( root, uploaded_file ) ) if os.path.split( uploaded_file_name )[ -1 ] == 'repository_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == 'tool_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) if ok: repo_path = os.path.join( full_path, relative_path ) @@ -328,15 +328,15 @@ uploaded_file_name = os.path.join( full_path, filename ) if os.path.split( uploaded_file_name )[ -1 ] == 'repository_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == 'tool_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) return commit_util.handle_directory_changes( trans, repository, diff -r 966fbc93c483970092b677f17886e86060941093 -r 0acfbcd4235b989f81c580c434471f1e657f298a lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -9,7 +9,7 @@ from galaxy.web import url_for import tool_shed.util.shed_util_common as suc from tool_shed.util import tool_util - +import xml.etree.ElementTree from galaxy import eggs eggs.require( 'mercurial' ) @@ -17,9 +17,6 @@ from mercurial import hg from mercurial import ui -pkg_resources.require( 'elementtree' ) -from elementtree.ElementTree import tostring - log = logging.getLogger( __name__ ) UNDESIRABLE_DIRS = [ '.hg', '.svn', '.git', '.cvs' ] @@ -64,12 +61,13 @@ return message def create_and_write_tmp_file( root ): + tmp_str = '%s\n' % xml.etree.ElementTree.tostring( root, encoding='utf-8' ) fh = tempfile.NamedTemporaryFile( 'wb' ) tmp_filename = fh.name fh.close() fh = open( tmp_filename, 'wb' ) fh.write( '<?xml version="1.0"?>\n' ) - fh.write( tostring( root, 'utf-8' ) ) + fh.write( tmp_str ) fh.close() return tmp_filename @@ -200,7 +198,7 @@ altered = False try: # Make sure we're looking at a valid repository_dependencies.xml file. - tree = util.parse_xml( repository_dependencies_config ) + tree = suc.parse_xml( repository_dependencies_config ) root = tree.getroot() except Exception, e: error_message = "Error parsing %s in handle_repository_dependencies_definition: " % str( repository_dependencies_config ) @@ -247,7 +245,7 @@ altered = False try: # Make sure we're looking at a valid tool_dependencies.xml file. - tree = util.parse_xml( tool_dependencies_config ) + tree = suc.parse_xml( tool_dependencies_config ) root = tree.getroot() except Exception, e: error_message = "Error parsing %s in handle_tool_dependencies_definition: " % str( tool_dependencies_config ) diff -r 966fbc93c483970092b677f17886e86060941093 -r 0acfbcd4235b989f81c580c434471f1e657f298a lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -14,6 +14,7 @@ from galaxy.model.orm import and_ import sqlalchemy.orm.exc from tool_shed.util import common_util +from xml.etree import ElementTree as XmlET from galaxy import eggs import pkg_resources @@ -36,6 +37,17 @@ MAX_DISPLAY_SIZE = 32768 VALID_CHARS = set( string.letters + string.digits + "'\"-=_.()/+*^,:?!#[]%\\$@;{}&<>" ) + +class CommentedTreeBuilder ( XmlET.XMLTreeBuilder ): + def __init__ ( self, html=0, target=None ): + XmlET.XMLTreeBuilder.__init__( self, html, target ) + self._parser.CommentHandler = self.handle_comment + + def handle_comment ( self, data ): + self._target.start( XmlET.Comment, {} ) + self._target.data( data ) + self._target.end( XmlET.Comment ) + new_repo_email_alert_template = """ Sharable link: ${sharable_link} Repository name: ${repository_name} @@ -1072,6 +1084,13 @@ prior_installation_required = util.asbool( str( prior_installation_required ) ) return tool_shed, name, owner, changeset_revision, prior_installation_required +def parse_xml( fname ): + """Returns a parsed xml tree with comments in tact.""" + fobj = open( fname, 'r' ) + tree = XmlET.parse( fobj, parser=CommentedTreeBuilder() ) + fobj.close() + return tree + def pretty_print( dict=None ): if dict: return json.to_json_string( dict, sort_keys=True, indent=4 * ' ' ) https://bitbucket.org/galaxy/galaxy-central/commits/1e006b5275f5/ Changeset: 1e006b5275f5 User: greg Date: 2013-05-23 17:50:16 Summary: Merged from next-stable Affected #: 3 files diff -r 1e601ee269763ebc51a42b757f5bd6d93b9f8fc4 -r 1e006b5275f5d3fce99f98b3e6cb00454d5e3c3d lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -129,18 +129,18 @@ # Move some version of the uploaded file to the load_point within the repository hierarchy. if uploaded_file_filename in [ 'repository_dependencies.xml' ]: # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, full_path ) else: shutil.move( uploaded_file_name, full_path ) elif uploaded_file_filename in [ 'tool_dependencies.xml' ]: # Inspect the contents of the file to see if it defines a complex repository dependency definition whose changeset_revision values # are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, full_path ) else: shutil.move( uploaded_file_name, full_path ) @@ -266,15 +266,15 @@ uploaded_file_name = os.path.abspath( os.path.join( root, uploaded_file ) ) if os.path.split( uploaded_file_name )[ -1 ] == 'repository_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == 'tool_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) if ok: repo_path = os.path.join( full_path, relative_path ) @@ -328,15 +328,15 @@ uploaded_file_name = os.path.join( full_path, filename ) if os.path.split( uploaded_file_name )[ -1 ] == 'repository_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == 'tool_dependencies.xml': # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) + altered, root_elem = commit_util.handle_tool_dependencies_definition( trans, uploaded_file_name ) if altered: - tmp_filename = commit_util.create_and_write_tmp_file( root ) + tmp_filename = commit_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) return commit_util.handle_directory_changes( trans, repository, diff -r 1e601ee269763ebc51a42b757f5bd6d93b9f8fc4 -r 1e006b5275f5d3fce99f98b3e6cb00454d5e3c3d lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -9,7 +9,7 @@ from galaxy.web import url_for import tool_shed.util.shed_util_common as suc from tool_shed.util import tool_util - +import xml.etree.ElementTree from galaxy import eggs eggs.require( 'mercurial' ) @@ -17,9 +17,6 @@ from mercurial import hg from mercurial import ui -pkg_resources.require( 'elementtree' ) -from elementtree.ElementTree import tostring - log = logging.getLogger( __name__ ) UNDESIRABLE_DIRS = [ '.hg', '.svn', '.git', '.cvs' ] @@ -64,12 +61,13 @@ return message def create_and_write_tmp_file( root ): + tmp_str = '%s\n' % xml.etree.ElementTree.tostring( root, encoding='utf-8' ) fh = tempfile.NamedTemporaryFile( 'wb' ) tmp_filename = fh.name fh.close() fh = open( tmp_filename, 'wb' ) fh.write( '<?xml version="1.0"?>\n' ) - fh.write( tostring( root, 'utf-8' ) ) + fh.write( tmp_str ) fh.close() return tmp_filename @@ -200,7 +198,7 @@ altered = False try: # Make sure we're looking at a valid repository_dependencies.xml file. - tree = util.parse_xml( repository_dependencies_config ) + tree = suc.parse_xml( repository_dependencies_config ) root = tree.getroot() except Exception, e: error_message = "Error parsing %s in handle_repository_dependencies_definition: " % str( repository_dependencies_config ) @@ -247,7 +245,7 @@ altered = False try: # Make sure we're looking at a valid tool_dependencies.xml file. - tree = util.parse_xml( tool_dependencies_config ) + tree = suc.parse_xml( tool_dependencies_config ) root = tree.getroot() except Exception, e: error_message = "Error parsing %s in handle_tool_dependencies_definition: " % str( tool_dependencies_config ) diff -r 1e601ee269763ebc51a42b757f5bd6d93b9f8fc4 -r 1e006b5275f5d3fce99f98b3e6cb00454d5e3c3d lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -14,6 +14,7 @@ from galaxy.model.orm import and_ import sqlalchemy.orm.exc from tool_shed.util import common_util +from xml.etree import ElementTree as XmlET from galaxy import eggs import pkg_resources @@ -36,6 +37,17 @@ MAX_DISPLAY_SIZE = 32768 VALID_CHARS = set( string.letters + string.digits + "'\"-=_.()/+*^,:?!#[]%\\$@;{}&<>" ) + +class CommentedTreeBuilder ( XmlET.XMLTreeBuilder ): + def __init__ ( self, html=0, target=None ): + XmlET.XMLTreeBuilder.__init__( self, html, target ) + self._parser.CommentHandler = self.handle_comment + + def handle_comment ( self, data ): + self._target.start( XmlET.Comment, {} ) + self._target.data( data ) + self._target.end( XmlET.Comment ) + new_repo_email_alert_template = """ Sharable link: ${sharable_link} Repository name: ${repository_name} @@ -1072,6 +1084,13 @@ prior_installation_required = util.asbool( str( prior_installation_required ) ) return tool_shed, name, owner, changeset_revision, prior_installation_required +def parse_xml( fname ): + """Returns a parsed xml tree with comments in tact.""" + fobj = open( fname, 'r' ) + tree = XmlET.parse( fobj, parser=CommentedTreeBuilder() ) + fobj.close() + return tree + def pretty_print( dict=None ): if dict: return json.to_json_string( dict, sort_keys=True, indent=4 * ' ' ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org