mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 02:04:04 +08:00
Merge pull request #1489 from nsoranzo/flake8_fixes
Fix all E731 "errors".
This commit is contained in:
@@ -1398,7 +1398,6 @@ class History( object, Dictifiable, UsesAnnotations, HasName ):
|
||||
assert db_session is not None
|
||||
query = db_session.query( content_class ).filter( content_class.table.c.history_id == self.id )
|
||||
query = query.order_by( content_class.table.c.hid.asc() )
|
||||
python_filter = None
|
||||
deleted = galaxy.util.string_as_bool_or_none( kwds.get( 'deleted', None ) )
|
||||
if deleted is not None:
|
||||
query = query.filter( content_class.deleted == deleted )
|
||||
@@ -1411,11 +1410,8 @@ class History( object, Dictifiable, UsesAnnotations, HasName ):
|
||||
if len(ids) < max_in_filter_length:
|
||||
query = query.filter( content_class.id.in_(ids) )
|
||||
else:
|
||||
python_filter = lambda content: content.id in ids
|
||||
if python_filter:
|
||||
return ifilter(python_filter, query)
|
||||
else:
|
||||
return query
|
||||
query = ifilter(lambda content: content.id in ids, query)
|
||||
return query
|
||||
|
||||
def __collection_contents_iter( self, **kwds ):
|
||||
return self.__filter_contents( HistoryDatasetCollectionAssociation, **kwds )
|
||||
|
||||
@@ -232,7 +232,8 @@ def total_size(o, handlers={}, verbose=False):
|
||||
|
||||
Recipe from: https://code.activestate.com/recipes/577504-compute-memory-footprint-of-an-object-and-its-cont/
|
||||
"""
|
||||
dict_handler = lambda d: chain.from_iterable(d.items())
|
||||
def dict_handler(d):
|
||||
return chain.from_iterable(d.items())
|
||||
all_handlers = { tuple: iter,
|
||||
list: iter,
|
||||
deque: iter,
|
||||
|
||||
@@ -754,7 +754,8 @@ class BaseURLToolParameter( HiddenToolParameter ):
|
||||
return d
|
||||
|
||||
|
||||
DEFAULT_VALUE_MAP = lambda x: x
|
||||
def DEFAULT_VALUE_MAP(x):
|
||||
return x
|
||||
|
||||
|
||||
def parse_dynamic_options(param, input_source):
|
||||
@@ -1873,9 +1874,11 @@ class DataToolParameter( BaseDataToolParameter ):
|
||||
|
||||
def _get_select_dataset_collection_fields( self, history, dataset_matcher, multiple=False, suffix="|__collection_multirun__", reduction=False ):
|
||||
if not reduction:
|
||||
value_modifier = lambda x: x
|
||||
def value_modifier(x):
|
||||
return x
|
||||
else:
|
||||
value_modifier = lambda value: "__collection_reduce__|%s" % value
|
||||
def value_modifier(value):
|
||||
return "__collection_reduce__|%s" % value
|
||||
|
||||
value = dataset_matcher.value
|
||||
if value is not None:
|
||||
|
||||
@@ -593,7 +593,9 @@ def parse_cast_attribute( cast ):
|
||||
elif cast == 'str':
|
||||
cast = str
|
||||
else:
|
||||
cast = lambda x: x # return value as-is
|
||||
# return value as-is
|
||||
def cast(x):
|
||||
return x
|
||||
return cast
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
import galaxy.tools.parameters.basic
|
||||
import galaxy.tools.parameters.grouping
|
||||
from galaxy.util import string_as_bool
|
||||
|
||||
try:
|
||||
from nose.tools import nottest
|
||||
except ImportError:
|
||||
nottest = lambda x: x
|
||||
import logging
|
||||
def nottest(x):
|
||||
return x
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
@@ -74,11 +76,15 @@ class ToolTestBuilder( object ):
|
||||
query_value = test_param.checked
|
||||
else:
|
||||
query_value = _process_bool_param_value( test_param, declared_value )
|
||||
matches_declared_value = lambda case_value: _process_bool_param_value( test_param, case_value ) == query_value
|
||||
|
||||
def matches_declared_value(case_value):
|
||||
return _process_bool_param_value( test_param, case_value ) == query_value
|
||||
elif isinstance(test_param, galaxy.tools.parameters.basic.SelectToolParameter):
|
||||
if declared_value is not None:
|
||||
# Test case supplied explicit value to check against.
|
||||
matches_declared_value = lambda case_value: case_value == declared_value
|
||||
|
||||
def matches_declared_value(case_value):
|
||||
return case_value == declared_value
|
||||
elif test_param.static_options:
|
||||
# No explicit value in test case, not much to do if options are dynamic but
|
||||
# if static options are available can find the one specified as default or
|
||||
@@ -90,7 +96,9 @@ class ToolTestBuilder( object ):
|
||||
first_option = test_param.static_options[0]
|
||||
first_option_value = first_option[1]
|
||||
default_option = first_option_value
|
||||
matches_declared_value = lambda case_value: case_value == default_option
|
||||
|
||||
def matches_declared_value(case_value):
|
||||
return case_value == default_option
|
||||
else:
|
||||
# No explicit value for this param and cannot determine a
|
||||
# default - give up. Previously this would just result in a key
|
||||
|
||||
@@ -53,10 +53,11 @@ class ToolSection( Dictifiable, HasPanelItems, object ):
|
||||
def __init__( self, item=None ):
|
||||
""" Build a ToolSection from an ElementTree element or a dictionary.
|
||||
"""
|
||||
f = lambda item, val: item is not None and item.get( val ) or ''
|
||||
self.name = f( item, 'name' )
|
||||
self.id = f( item, 'id' )
|
||||
self.version = f( item, 'version' )
|
||||
if item is None:
|
||||
item = dict()
|
||||
self.name = item.get('name') or ''
|
||||
self.id = item.get('id') or ''
|
||||
self.version = item.get('version') or ''
|
||||
self.elems = ToolPanelElements()
|
||||
|
||||
def copy( self ):
|
||||
|
||||
@@ -12,9 +12,12 @@ log = getLogger( __name__ )
|
||||
# remote ComputeEnvironments (such as one used by Pulsar) determine what values to
|
||||
# rewrite or transfer...
|
||||
PATH_ATTRIBUTES = [ "path" ]
|
||||
|
||||
|
||||
# ... by default though - don't rewrite anything (if no ComputeEnviornment
|
||||
# defined or ComputeEnvironment doesn't supply a rewriter).
|
||||
DEFAULT_PATH_REWRITER = lambda x: x
|
||||
def DEFAULT_PATH_REWRITER(x):
|
||||
return x
|
||||
|
||||
|
||||
class ToolParameterValueWrapper( object ):
|
||||
|
||||
@@ -94,7 +94,8 @@ INVALID_CHARACTER = "X"
|
||||
|
||||
if sys.version_info > (3, 0):
|
||||
# __coerce__ doesn't do anything under Python anyway.
|
||||
coerce = lambda x, y: x
|
||||
def coerce(x, y):
|
||||
return x
|
||||
|
||||
|
||||
def sanitize_lists_to_string( values, valid_characters=VALID_CHARACTERS, character_map=CHARACTER_MAP, invalid_character=INVALID_CHARACTER ):
|
||||
|
||||
@@ -7,12 +7,13 @@ from __future__ import with_statement
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import sys
|
||||
|
||||
from galaxy.util.properties import NicerConfigParser
|
||||
|
||||
import pkg_resources
|
||||
from six import iteritems
|
||||
|
||||
__all__ = ['loadapp', 'loadserver', 'loadfilter', 'appconfig']
|
||||
|
||||
@@ -31,15 +32,11 @@ def print_(template, *args, **kwargs):
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
from urllib import unquote
|
||||
iteritems = lambda d: d.iteritems()
|
||||
dictkeys = lambda d: d.keys()
|
||||
|
||||
def reraise(t, e, tb):
|
||||
exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
|
||||
else:
|
||||
from urllib.parse import unquote
|
||||
iteritems = lambda d: d.items()
|
||||
dictkeys = lambda d: list(d.keys())
|
||||
|
||||
def reraise(t, e, tb):
|
||||
exec('raise e from tb', dict(e=e, tb=tb))
|
||||
@@ -703,7 +700,7 @@ class EggLoader(_Loader):
|
||||
dist.location,
|
||||
', '.join(_flatten(object_type.egg_protocols)),
|
||||
', '.join(_flatten([
|
||||
dictkeys(pkg_resources.get_entry_info(self.spec, prot, name) or {})
|
||||
list((pkg_resources.get_entry_info(self.spec, prot, name) or {}).keys())
|
||||
for prot in protocol_options] or '(no entry points)'))))
|
||||
if len(possible) > 1:
|
||||
raise LookupError(
|
||||
|
||||
@@ -260,9 +260,12 @@ class Genomes( object ):
|
||||
# Add app keys to dbkeys.
|
||||
|
||||
# If chrom_info is True, only include keys with len files (which contain chromosome info).
|
||||
filter_fn = lambda b: True
|
||||
if chrom_info:
|
||||
filter_fn = lambda b: b.len_file is not None
|
||||
def filter_fn(b):
|
||||
return b.len_file is not None
|
||||
else:
|
||||
def filter_fn(b):
|
||||
return True
|
||||
|
||||
dbkeys.extend( [ ( genome.description, genome.key ) for key, genome in self.genomes.items() if filter_fn( genome ) ] )
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ except ImportError:
|
||||
oidutil = None
|
||||
|
||||
class FakeConsumer( object ):
|
||||
__getattr__ = lambda x, y: None
|
||||
def __getattr__(x, y):
|
||||
return None
|
||||
consumer = FakeConsumer()
|
||||
|
||||
|
||||
|
||||
@@ -5,5 +5,4 @@
|
||||
# 203 whitespace before ':'
|
||||
# 402 module level import not at top of file # TODO, we would like to improve this.
|
||||
# 501 is line length
|
||||
# E731 is inline assigned lambdas -- #TODO this should be revisited to see if we want to change our usage.
|
||||
ignore = E128,E201,E202,E203,E501,E402,E731
|
||||
ignore = E128,E201,E202,E203,E501,E402
|
||||
|
||||
+7
-3
@@ -416,11 +416,15 @@ class BaseDatasetCollectionPopulator( object ):
|
||||
# 2-tuples of form (name, dataset_content).
|
||||
if contents and isinstance(contents[0], tuple):
|
||||
hdas = self.__datasets( history_id, count=count, contents=[c[1] for c in contents] )
|
||||
hda_to_identifier = lambda ( i, hda ): dict( name=contents[i][0], src="hda", id=hda[ "id" ] )
|
||||
|
||||
def hda_to_identifier(i, hda):
|
||||
return dict(name=contents[i][0], src="hda", id=hda["id"])
|
||||
else:
|
||||
hdas = self.__datasets( history_id, count=count, contents=contents )
|
||||
hda_to_identifier = lambda ( i, hda ): dict( name="data%d" % ( i + 1 ), src="hda", id=hda[ "id" ] )
|
||||
element_identifiers = map( hda_to_identifier, enumerate( hdas ) )
|
||||
|
||||
def hda_to_identifier(i, hda):
|
||||
return dict(name="data%d" % (i + 1), src="hda", id=hda["id"])
|
||||
element_identifiers = [hda_to_identifier(i, hda) for (i, hda) in enumerate(hdas)]
|
||||
return element_identifiers
|
||||
|
||||
def __create( self, payload ):
|
||||
|
||||
@@ -200,15 +200,12 @@ class CasperJSTestCase( unittest.TestCase ):
|
||||
"""Converts the headless' error from JSON into a more informative
|
||||
python HeadlessJSJavascriptError.
|
||||
"""
|
||||
get_error = lambda d: d[ 'errors' ][0]
|
||||
get_msg = lambda err: err[ 'msg' ]
|
||||
get_trace = lambda err: err[ 'backtrace' ]
|
||||
try:
|
||||
# assume it's json and located in errors (and first)
|
||||
js_test_results = json.loads( stdout_output )
|
||||
last_error = get_error( js_test_results )
|
||||
err_string = ( "%s\n%s" % ( get_msg( last_error ),
|
||||
self.browser_backtrace_to_string( get_trace( last_error ) ) ) )
|
||||
last_error = js_test_results['errors'][0]
|
||||
err_string = ( "%s\n%s" % ( last_error['msg'],
|
||||
self.browser_backtrace_to_string( last_error['backtrace'] ) ) )
|
||||
|
||||
# if we couldn't parse json from what's returned on the error, dump stdout
|
||||
except ValueError, val_err:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import new
|
||||
import sys
|
||||
from base.twilltestcase import TwillTestCase
|
||||
@@ -6,11 +7,12 @@ from base.interactor import build_interactor, stage_data_in_history, RunToolExce
|
||||
from base.instrument import register_job_data
|
||||
from galaxy.tools import DataManagerTool
|
||||
from galaxy.util import bunch
|
||||
import logging
|
||||
|
||||
try:
|
||||
from nose.tools import nottest
|
||||
except ImportError:
|
||||
nottest = lambda x: x
|
||||
def nottest(x):
|
||||
return x
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
@@ -146,10 +146,10 @@ class ToolExecutionTestCase( TestCase, tools_support.UsesApp, tools_support.Uses
|
||||
collection = galaxy.model.DatasetCollection(
|
||||
collection_type=collection_type,
|
||||
)
|
||||
to_element = lambda hda: galaxy.model.DatasetCollectionElement(
|
||||
collection=collection,
|
||||
element=hda,
|
||||
)
|
||||
|
||||
def to_element(hda):
|
||||
return galaxy.model.DatasetCollectionElement(collection=collection,
|
||||
element=hda)
|
||||
elements = map(to_element, hdas)
|
||||
if collection_type == "list:paired":
|
||||
paired_collection = galaxy.model.DatasetCollection(
|
||||
|
||||
Reference in New Issue
Block a user