Remove unused libraries
- remove tabulate + remove dead code in CLI - remove multipledispatch + reimplement simple wrapper in __init__ Change-Id: I8503179c05477b9075845e740738f3e355a72cf5 Closes-bug: #1548314
This commit is contained in:
parent
e26f0083bb
commit
add50899b9
@ -10,14 +10,12 @@ dictdiffer==0.4.0
|
||||
enum34==1.0.4
|
||||
inflection
|
||||
Fabric==1.10.2
|
||||
tabulate==0.7.5
|
||||
gevent>=1.0.2
|
||||
|
||||
# we need callbacks for now
|
||||
ansible
|
||||
|
||||
mock
|
||||
multipledispatch==0.4.8
|
||||
pbr
|
||||
pydotplus
|
||||
bunch
|
||||
|
@ -17,7 +17,6 @@ import os
|
||||
|
||||
import click
|
||||
from functools import wraps
|
||||
import tabulate
|
||||
import yaml
|
||||
|
||||
from solar.cli.base import EGroup
|
||||
@ -164,26 +163,11 @@ def update(name, args):
|
||||
|
||||
|
||||
@resource.command()
|
||||
@click.option('--check-missing-connections', default=False, is_flag=True)
|
||||
def validate(check_missing_connections):
|
||||
def validate():
|
||||
errors = sresource.validate_resources()
|
||||
for r, error in errors:
|
||||
click.echo('ERROR: %s: %s' % (r.name, error))
|
||||
|
||||
if check_missing_connections:
|
||||
missing_connections = cr.find_missing_connections()
|
||||
if missing_connections:
|
||||
click.echo(
|
||||
'The following resources have inputs of the same value '
|
||||
'but are not connected:'
|
||||
)
|
||||
click.echo(
|
||||
tabulate.tabulate([
|
||||
['%s::%s' % (r1, i1), '%s::%s' % (r2, i2)]
|
||||
for r1, i1, r2, i2 in missing_connections
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
@resource.command()
|
||||
@click.argument('path', type=click.Path(exists=True, dir_okay=False))
|
||||
|
@ -21,10 +21,8 @@ import os
|
||||
from uuid import uuid4
|
||||
|
||||
from enum import Enum
|
||||
from multipledispatch import dispatch
|
||||
import networkx
|
||||
|
||||
|
||||
from solar.computable_inputs import ComputablePassedTypes
|
||||
from solar.core.resource.repository import read_meta
|
||||
from solar.core.resource.repository import Repository
|
||||
@ -48,8 +46,7 @@ class Resource(object):
|
||||
_metadata = {}
|
||||
|
||||
# Create
|
||||
@dispatch(basestring, basestring)
|
||||
def __init__(self, name, spec, args=None, tags=None):
|
||||
def create_from_spec(self, name, spec, args=None, tags=None):
|
||||
args = args or {}
|
||||
self.name = name
|
||||
if spec:
|
||||
@ -95,12 +92,25 @@ class Resource(object):
|
||||
self.db_obj.save()
|
||||
|
||||
# Load
|
||||
@dispatch(object) # noqa
|
||||
def __init__(self, resource_db):
|
||||
def create_from_db(self, resource_db):
|
||||
self.db_obj = resource_db
|
||||
self.name = resource_db.name
|
||||
self.base_path = resource_db.base_path
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if len(args) == 1:
|
||||
return self.create_from_db(args[0])
|
||||
elif len(args) == 0 and 'resource_db' in kwargs:
|
||||
return self.create_from_db(**kwargs)
|
||||
args_names = ('name', 'spec', 'args', 'tags')
|
||||
for i, arg in enumerate(args):
|
||||
kwargs[args_names[i]] = arg
|
||||
if isinstance(kwargs[args_names[0]], basestring) and \
|
||||
isinstance(kwargs[args_names[1]], basestring):
|
||||
return self.create_from_spec(**kwargs)
|
||||
raise RuntimeError("Failed to create Resoruce object "
|
||||
"from args: %r and kwargs: %r" % (args, kwargs))
|
||||
|
||||
def auto_extend_inputs(self, inputs):
|
||||
# XXX: we didn't agree on `location_id` and `transports_id`
|
||||
# that are added automaticaly to all resources
|
||||
|
Loading…
x
Reference in New Issue
Block a user