code cleaning
This commit is contained in:
parent
ec62dc0c76
commit
01a6f32403
|
@ -67,7 +67,7 @@ class D4S_IS_DiscoveryCatalogueNamespaces():
|
|||
bodyToString = etree.tostring(theNamespaces[0])
|
||||
doc = xmltodict.parse(bodyToString)
|
||||
else:
|
||||
log.warn("No Namespace for Catalogue Categories found, returning None")
|
||||
log.warning("No Namespace for Catalogue Categories found, returning None")
|
||||
except Exception as inst:
|
||||
log.error("Error on getting catalogue namespaces: " + str(inst))
|
||||
log.info("Returning empty list of namespaces")
|
||||
|
|
|
@ -323,8 +323,6 @@ def purge_namespace_to_string(facet):
|
|||
return ""
|
||||
|
||||
facet_name = g.search_facets.get(facet)
|
||||
print("facet_name " + str(facet_name))
|
||||
#logging.debug("facet_name " + str(facet_name)) preferibile in flask
|
||||
end = str(facet_name).index(":")
|
||||
if end <= len(facet_name):
|
||||
return facet_name[:end]
|
||||
|
@ -345,8 +343,7 @@ def count_facet_items_dict(facet, limit=None, exclude_active=False):
|
|||
elif not exclude_active:
|
||||
facets.append(dict(active=True, **facet_item))
|
||||
|
||||
# for count,
|
||||
# print "facets " + str(facets)
|
||||
# for count,
|
||||
total = len(facets)
|
||||
log.debug("total facet: %s are %d" % (facet, total))
|
||||
return total
|
||||
|
@ -363,13 +360,10 @@ def check_url(the_url):
|
|||
urllib.request.urlopen(the_url)
|
||||
return True
|
||||
except urllib.error.HTTPError as e:
|
||||
# print(e.code)
|
||||
return False
|
||||
except urllib.error.URLError as e:
|
||||
# print(e.args)
|
||||
return False
|
||||
except Exception as error:
|
||||
# print(error)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -377,7 +371,6 @@ def get_color_for_type(systemtype_field_value):
|
|||
'''Return a color assigned to a system type'''
|
||||
|
||||
systemtypecolors = session.get(systemtype_field_colors)
|
||||
# log.info("color: getting color for type: %s" %systemtype_field_value)
|
||||
|
||||
if systemtypecolors is None:
|
||||
log.info("color: " + systemtype_field_colors + " not found in session, creating new one")
|
||||
|
@ -404,7 +397,6 @@ def get_color_for_type(systemtype_field_value):
|
|||
|
||||
|
||||
def ordered_dictionary(list_to_be_sorted, property='name', ordering="asc"):
|
||||
# print ("dict %s" %list_to_be_sorted)
|
||||
|
||||
ord = False if ordering == "asc" else True
|
||||
|
||||
|
@ -470,8 +462,7 @@ def get_list_of_organizations(limit=10, sort='packages'):
|
|||
|
||||
to_browse_organizations.append(to_browse_obj)
|
||||
except (logic.NotFound, logic.ValidationError, logic.NotAuthorized) as error:
|
||||
# SILENT
|
||||
log.warn("Error on putting organization: %s" % error)
|
||||
log.warning("Error on putting organization: %s" % error)
|
||||
|
||||
log.info("browse %d" % len(ordered_organizations) + " organisation/s")
|
||||
except (logic.NotFound, logic.ValidationError, logic.NotAuthorized) as error:
|
||||
|
@ -494,7 +485,6 @@ def get_list_of_groups(limit=10, sort='package_count'):
|
|||
ordered_groups = logic.get_action('group_list')({}, data)
|
||||
|
||||
for group in ordered_groups:
|
||||
# print "\n\ngroup %s" %group
|
||||
try:
|
||||
to_browse_obj = {}
|
||||
|
||||
|
@ -516,8 +506,7 @@ def get_list_of_groups(limit=10, sort='package_count'):
|
|||
|
||||
to_browse_groups.append(to_browse_obj)
|
||||
except (logic.NotFound, logic.ValidationError, logic.NotAuthorized) as error:
|
||||
# SILENT
|
||||
log.warn("Error on putting group: %s" % error)
|
||||
log.warning("Error on putting group: %s" % error)
|
||||
|
||||
log.info("browse %d" % len(ordered_groups) + " organisation/s")
|
||||
except (logic.NotFound, logic.ValidationError, logic.NotAuthorized) as error:
|
||||
|
|
|
@ -9,12 +9,7 @@ from ckanext.d4science.logic import validators
|
|||
from ckan.config.middleware.common_middleware import TrackingMiddleware
|
||||
from ckan.model import Package
|
||||
from logging import getLogger
|
||||
|
||||
from ckan.common import (
|
||||
g
|
||||
)
|
||||
|
||||
d4s_ctg_namespaces_controller = None
|
||||
from flask import g
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
@ -51,7 +46,7 @@ def _package_extras_save(extra_dicts, obj, context):
|
|||
#print 'extra_dict key: '+extra_dict["key"] + ', value: '+extra_dict["value"]
|
||||
#new_extras.setdefault(extra_dict["key"], []).append(extra_dict["value"])
|
||||
if extra_dict.get("deleted"):
|
||||
log.debug("extra_dict deleted: "+unicode(extra_dict["key"]).encode('utf-8'))
|
||||
log.debug("extra_dict deleted: "+str(extra_dict["key"]))
|
||||
#print 'extra_dict deleted: '+extra_dict["key"]
|
||||
continue
|
||||
|
||||
|
@ -289,22 +284,10 @@ class D4SciencePlugin(plugins.SingletonPlugin):
|
|||
#OVERRIDING BASE SQL ALCHEMY ENGINE INSTANCE
|
||||
TrackingMiddleware.__init__ = _init_TrackingMiddleware
|
||||
|
||||
global d4s_ctg_namespaces_controller
|
||||
|
||||
# IBlueprint
|
||||
|
||||
# def get_blueprint(self):
|
||||
# return views.get_blueprints()
|
||||
|
||||
def get_blueprint(self):
|
||||
blueprint = Blueprint('foo', self.__module__)
|
||||
# rules = [
|
||||
# ('/group', 'group_index', custom_group_index),
|
||||
# ]
|
||||
# for rule in rules:
|
||||
# blueprint.add_url_rule(*rule)
|
||||
|
||||
return blueprint
|
||||
return views.get_blueprints()
|
||||
|
||||
# IClick
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from flask import Blueprint
|
||||
|
||||
from ckanext.d4science.controllers.home import d4science_home
|
||||
from ckanext.d4science.controllers.organization import organization_vre
|
||||
from ckanext.d4science.controllers.systemtype import d4s_type_blueprint
|
||||
|
||||
|
||||
d4science = Blueprint(
|
||||
"d4science", __name__)
|
||||
|
@ -14,4 +18,5 @@ d4science.add_url_rule(
|
|||
|
||||
|
||||
def get_blueprints():
|
||||
return [d4science]
|
||||
all_blueprints = [d4science, d4science_home, organization_vre, d4s_type_blueprint]
|
||||
return all_blueprints
|
||||
|
|
Loading…
Reference in New Issue