Skip to content

Commit

Permalink
Change __all__ from list to tuple
Browse files Browse the repository at this point in the history
Also fix import order and Python3 compatibility.
  • Loading branch information
nsoranzo committed Oct 13, 2016
1 parent c6713e7 commit 77f78cf
Show file tree
Hide file tree
Showing 52 changed files with 226 additions and 216 deletions.
17 changes: 14 additions & 3 deletions .ci/flake8_lint_include_list.txt
Expand Up @@ -95,6 +95,7 @@ lib/galaxy/main.py
lib/galaxy/managers/annotatable.py
lib/galaxy/managers/api_keys.py
lib/galaxy/managers/base.py
lib/galaxy/managers/collections_util.py
lib/galaxy/managers/context.py
lib/galaxy/managers/deletable.py
lib/galaxy/managers/__init__.py
Expand All @@ -103,7 +104,9 @@ lib/galaxy/managers/libraries.py
lib/galaxy/managers/secured.py
lib/galaxy/managers/taggable.py
lib/galaxy/model/__init__.py
lib/galaxy/model/item_attrs.py
lib/galaxy/model/mapping.py
lib/galaxy/model/metadata.py
lib/galaxy/model/migrate/__init__.py
lib/galaxy/model/migrate/versions/0001_initial_tables.py
lib/galaxy/model/migrate/versions/0002_metadata_file_table.py
Expand Down Expand Up @@ -246,21 +249,27 @@ lib/galaxy/sample_tracking/sample.py
lib/galaxy/security/validate_user_input.py
lib/galaxy/tags/
lib/galaxy/tools/actions/metadata.py
lib/galaxy/tools/cwl
lib/galaxy/tools/cwl/
lib/galaxy/tools/data_manager/__init__.py
lib/galaxy/tools/deps
lib/galaxy/tools/deps/
lib/galaxy/tools/exception_handling.py
lib/galaxy/tools/execute.py
lib/galaxy/tools/filters/
lib/galaxy/tools/imp_exp/export_history.py
lib/galaxy/tools/imp_exp/__init__.py
lib/galaxy/tools/linters/
lib/galaxy/tools/lint.py
lib/galaxy/tools/lint_util.py
lib/galaxy/tools/loader_directory.py
lib/galaxy/tools/loader.py
lib/galaxy/tools/parameters/dataset_matcher.py
lib/galaxy/tools/parameters/history_query.py
lib/galaxy/tools/parameters/__init__.py
lib/galaxy/tools/parameters/input_translation.py
lib/galaxy/tools/parameters/sanitize.py
lib/galaxy/tools/parameters/validation.py
lib/galaxy/tools/parameters/wrapped_json.py
lib/galaxy/tools/parameters/wrapped.py
lib/galaxy/tools/parser/
lib/galaxy/tools/special_tools.py
lib/galaxy/tools/test.py
Expand Down Expand Up @@ -350,7 +359,8 @@ lib/galaxy/web/params.py
lib/galaxy/workflow/extract.py
lib/galaxy/workflow/__init__.py
lib/galaxy/workflow/render.py
lib/galaxy/workflow/schedulers/__init__.py
lib/galaxy/workflow/run.py
lib/galaxy/workflow/schedulers/
lib/galaxy/workflow/steps.py
lib/galaxy/work/__init__.py
lib/mimeparse.py
Expand Down Expand Up @@ -518,6 +528,7 @@ test/unit/tools/test_tool_deps.py
test/unit/tools/test_tool_loader.py
test/unit/tools/test_toolbox_filters.py
test/unit/tools/test_watcher.py
test/unit/tools_support.py
test/unit/unittest_utils/__init__.py
test/unit/unittest_utils/utility.py
test/unit/visualizations/__init__.py
Expand Down
12 changes: 12 additions & 0 deletions .ci/py3_sources.txt
Expand Up @@ -28,8 +28,11 @@ lib/galaxy/forms/
lib/galaxy/jobs/
lib/galaxy/managers/
lib/galaxy/model/__init__.py
lib/galaxy/model/item_attrs.py
lib/galaxy/model/mapping.py
lib/galaxy/model/metadata.py
lib/galaxy/model/migrate/
lib/galaxy/model/orm/now.py
lib/galaxy/objectstore/
lib/galaxy/openid/
lib/galaxy/quota/
Expand All @@ -38,17 +41,26 @@ lib/galaxy/security/
lib/galaxy/tags/
lib/galaxy/tools/cwl/
lib/galaxy/tools/deps/
lib/galaxy/tools/exception_handling.py
lib/galaxy/tools/execute.py
lib/galaxy/tools/lint.py
lib/galaxy/tools/lint_util.py
lib/galaxy/tools/linters/
lib/galaxy/tools/loader.py
lib/galaxy/tools/loader_directory.py
lib/galaxy/tools/parameters/dataset_matcher.py
lib/galaxy/tools/parameters/__init__.py
lib/galaxy/tools/parameters/wrapped_json.py
lib/galaxy/tools/parameters/wrapped.py
lib/galaxy/tools/parser/
lib/galaxy/tools/toolbox/
lib/galaxy/tours/
lib/galaxy/util/
lib/galaxy/visualization/
lib/galaxy/work/
lib/galaxy/workflow/extract.py
lib/galaxy/workflow/run.py
lib/galaxy/workflow/schedulers/core.py
lib/galaxy_ext/
lib/galaxy_utils/
lib/log_tempfile.py
Expand Down
13 changes: 6 additions & 7 deletions lib/galaxy/managers/collections_util.py
@@ -1,8 +1,7 @@
from galaxy import exceptions
from galaxy import web
from galaxy import model

import logging

from galaxy import exceptions, model, web

log = logging.getLogger( __name__ )

ERROR_MESSAGE_UNKNOWN_SRC = "Unknown dataset source (src) %s."
Expand Down Expand Up @@ -77,7 +76,7 @@ def dictify_dataset_collection_instance( dataset_collection_instance, parent, se
dict_value[ 'url' ] = web.url_for( 'library_content', library_id=encoded_library_id, id=encoded_id, folder_id=encoded_folder_id )
if view == "element":
collection = dataset_collection_instance.collection
dict_value[ 'elements' ] = map( dictify_element, collection.elements )
dict_value[ 'elements' ] = [ dictify_element(_) for _ in collection.elements ]
dict_value[ 'populated' ] = collection.populated
security.encode_all_ids( dict_value, recursive=True ) # TODO: Use Kyle's recursive formulation of this.
return dict_value
Expand All @@ -89,10 +88,10 @@ def dictify_element( element ):
if element.child_collection:
# Recursively yield elements for each nested collection...
child_collection = element.child_collection
object_detials[ "elements" ] = map( dictify_element, child_collection.elements )
object_detials[ "elements" ] = [ dictify_element(_) for _ in child_collection.elements ]
object_detials[ "populated" ] = child_collection.populated

dictified[ "object" ] = object_detials
return dictified

__all__ = [ api_payload_to_create_params, dictify_dataset_collection_instance ]
__all__ = ( 'api_payload_to_create_params', 'dictify_dataset_collection_instance' )
8 changes: 5 additions & 3 deletions lib/galaxy/model/item_attrs.py
@@ -1,7 +1,9 @@
import logging

from sqlalchemy.sql.expression import func

# Cannot import galaxy.model b/c it creates a circular import graph.
import galaxy
import logging

log = logging.getLogger( __name__ )

Expand Down Expand Up @@ -162,8 +164,8 @@ def _get_annotation_assoc_class( self, item ):
return getattr( galaxy.model, class_name, None )


__all__ = [
__all__ = (
'UsesAnnotations',
'UsesItemRatings',
'RuntimeException',
]
)
23 changes: 12 additions & 11 deletions lib/galaxy/model/metadata.py
Expand Up @@ -4,7 +4,6 @@
"""

import copy
import cPickle
import json
import logging
import os
Expand All @@ -15,6 +14,7 @@
from os.path import abspath

from six import string_types
from six.moves import cPickle
from sqlalchemy.orm import object_session

import galaxy.model
Expand Down Expand Up @@ -93,13 +93,14 @@ def get( self, key, default=None ):
return default

def items(self):
return iter( [ ( k, self.get( k ) ) for k in self.spec.iterkeys() ] )
return iter( [ ( k, self.get( k ) ) for k in self.spec.keys() ] )

def __str__(self):
return dict( self.items() ).__str__()

def __nonzero__( self ):
def __bool__( self ):
return bool( self.parent._metadata )
__nonzero__ = __bool__

def __getattr__( self, name ):
if name in self.spec:
Expand Down Expand Up @@ -205,7 +206,7 @@ def append( self, item ):
self[item.name] = item

def iter( self ):
return self.itervalues()
return iter(self.values())

def __getattr__( self, name ):
return self.get( name )
Expand Down Expand Up @@ -452,15 +453,15 @@ def get_html_field( self, value=None, context=None, other_values=None, values=No
other_values = other_values or {}

if values is None:
values = zip( range( self.min, self.max, self.step ), range( self.min, self.max, self.step ))
values = list(zip( range( self.min, self.max, self.step ), range( self.min, self.max, self.step ) ))
return SelectParameter.get_html_field( self, value=value, context=context, other_values=other_values, values=values, **kwd )

def get_html( self, value, context=None, other_values=None, values=None, **kwd ):
context = context or {}
other_values = other_values or {}

if values is None:
values = zip( range( self.min, self.max, self.step ), range( self.min, self.max, self.step ))
values = list(zip( range( self.min, self.max, self.step ), range( self.min, self.max, self.step ) ))
return SelectParameter.get_html( self, value, context=context, other_values=other_values, values=values, **kwd )

@classmethod
Expand All @@ -478,7 +479,7 @@ def get_html_field( self, value=None, context=None, other_values=None, values=No

if values is None and context:
column_range = range( 1, ( context.columns or 0 ) + 1, 1 )
values = zip( column_range, column_range )
values = list(zip( column_range, column_range ))
return RangeParameter.get_html_field( self, value=value, context=context, other_values=other_values, values=values, **kwd )

def get_html( self, value, context=None, other_values=None, values=None, **kwd ):
Expand All @@ -487,7 +488,7 @@ def get_html( self, value, context=None, other_values=None, values=None, **kwd )

if values is None and context:
column_range = range( 1, ( context.columns or 0 ) + 1, 1 )
values = zip( column_range, column_range )
values = list(zip( column_range, column_range ))
return RangeParameter.get_html( self, value, context=context, other_values=other_values, values=values, **kwd )


Expand Down Expand Up @@ -815,7 +816,7 @@ def __get_filename_override():
metadata_files.filename_override_metadata = abspath( tempfile.NamedTemporaryFile( dir=tmp_dir, prefix="metadata_override_%s_" % key ).name )
open( metadata_files.filename_override_metadata, 'wb+' ) # create the file on disk, so it cannot be reused by tempfile (unlikely, but possible)
override_metadata = []
for meta_key, spec_value in dataset.metadata.spec.iteritems():
for meta_key, spec_value in dataset.metadata.spec.items():
if isinstance( spec_value.param, FileParameter ) and dataset.metadata.get( meta_key, None ) is not None:
metadata_temp = MetadataTempFile()
shutil.copy( dataset.metadata.get( meta_key, None ).file_name, metadata_temp.file_name )
Expand Down Expand Up @@ -871,7 +872,7 @@ def set_job_runner_external_pid( self, pid, sa_session ):
sa_session.add( metadata_files )
sa_session.flush()

__all__ = [
__all__ = (
"Statement",
"MetadataElement",
"MetadataCollection",
Expand All @@ -889,4 +890,4 @@ def set_job_runner_external_pid( self, pid, sa_session ):
"FileParameter",
"MetadataTempFile",
"JobExternalOutputMetadataWrapper",
]
)
2 changes: 1 addition & 1 deletion lib/galaxy/model/orm/now.py
Expand Up @@ -10,4 +10,4 @@
# Return the current time in UTC without any timezone information
now = datetime.utcnow

__all__ = [now]
__all__ = ('now', )
7 changes: 3 additions & 4 deletions lib/galaxy/tools/cwl/__init__.py
Expand Up @@ -2,18 +2,17 @@
needs_shell_quoting,
shellescape,
)
from .parser import tool_proxy
from .parser import workflow_proxy
from .parser import tool_proxy, workflow_proxy
from .representation import to_cwl_job, to_galaxy_parameters
from .runtime_actions import handle_outputs


__all__ = [
__all__ = (
'tool_proxy',
'workflow_proxy',
'handle_outputs',
'to_cwl_job',
'to_galaxy_parameters',
'needs_shell_quoting',
'shellescape',
]
)
7 changes: 3 additions & 4 deletions lib/galaxy/tools/cwl/cwltool_deps.py
Expand Up @@ -4,6 +4,7 @@
:func:`ensure_cwltool_available` before using any of the imported
functionality at runtime.
"""
import re

try:
import requests
Expand Down Expand Up @@ -40,8 +41,6 @@
# Drop SyntaxError once schema_salad supports Python 3
schema_salad = None

import re

needs_shell_quoting = re.compile(r"""(^$|[\s|&;()<>\'"$@])""").search


Expand All @@ -65,7 +64,7 @@ def ensure_cwltool_available():
raise ImportError(message)


__all__ = [
__all__ = (
'main',
'load_tool',
'workflow',
Expand All @@ -74,4 +73,4 @@ def ensure_cwltool_available():
'schema_salad',
'shellescape',
'needs_shell_quoting',
]
)
16 changes: 9 additions & 7 deletions lib/galaxy/tools/cwl/parser.py
Expand Up @@ -10,6 +10,8 @@
import os
from abc import ABCMeta, abstractmethod

import six

from galaxy.util import safe_makedirs
from galaxy.util.bunch import Bunch
from galaxy.util.odict import odict
Expand Down Expand Up @@ -119,8 +121,8 @@ def check_requirements(rec, tool=True):
check_requirements(d, tool=tool)


@six.add_metaclass(ABCMeta)
class ToolProxy( object ):
__metaclass__ = ABCMeta

def __init__(self, tool, tool_path):
self._tool = tool
Expand Down Expand Up @@ -176,7 +178,7 @@ def _find_inputs(self, schema):
schema = self._tool.schemaDefs[schema_type]

if schema["type"] == "record":
return map(_simple_field_to_input, schema["fields"])
return [_simple_field_to_input(_) for _ in schema["fields"]]

def output_instances(self):
outputs_schema = self._tool.outputs_record_schema
Expand Down Expand Up @@ -235,12 +237,12 @@ def is_command_line_job(self):

def _ensure_cwl_job_initialized(self):
if self._cwl_job is None:
self._cwl_job = self._tool_proxy._tool.job(
self._cwl_job = next(self._tool_proxy._tool.job(
self._input_dict,
self._output_callback,
basedir=self._job_directory,
use_container=False
).next()
))
self._is_command_line_job = hasattr(self._cwl_job, "command_line")

@property
Expand Down Expand Up @@ -536,7 +538,7 @@ def to_dict(self):
when=odict(),
)
for value, block in self.whens:
as_dict["when"][value] = map(lambda i: i.to_dict(), block)
as_dict["when"][value] = [i.to_dict() for i in block]

return as_dict

Expand Down Expand Up @@ -616,7 +618,7 @@ def __init__(self, name, output_data_type, output_type, path=None):
self.path = path


__all__ = [
__all__ = (
'tool_proxy',
'load_job_proxy',
]
)

0 comments on commit 77f78cf

Please sign in to comment.