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