[saem-devel] [PATCH 06 of 10] Use relative imports when importing from this cube

saem-devel at lists.cubicweb.org saem-devel at lists.cubicweb.org
Wed Jan 25 10:05:04 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1485271134 -3600
#      Tue Jan 24 16:18:54 2017 +0100
# Node ID 18ac0aff97abd88cd40dbe63690bdaba7ab835a4
# Parent  7d342dd3b74f0de719a6607646075adc2fb88fe5
Use relative imports when importing from this cube

the occasion for a massive copyright update :)

diff --git a/cubicweb_saem_ref/__init__.py b/cubicweb_saem_ref/__init__.py
--- a/cubicweb_saem_ref/__init__.py
+++ b/cubicweb_saem_ref/__init__.py
@@ -107,11 +107,11 @@ def includeme(config):
 
 def _massive_store_factory(cnx, **kwargs):
     from cubicweb.dataimport.massive_store import MassiveObjectStore
-    from cubes.saem_ref.sobjects import SAEMMetadataGenerator
+    from .sobjects import SAEMMetadataGenerator
     return MassiveObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx), **kwargs)
 
 
 def _nohook_store_factory(cnx):
     from cubicweb.dataimport.stores import NoHooRQLObjectStore
-    from cubes.saem_ref.sobjects import SAEMMetadataGenerator
+    from .sobjects import SAEMMetadataGenerator
     return NoHooRQLObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx))
diff --git a/cubicweb_saem_ref/dataimport/eac.py b/cubicweb_saem_ref/dataimport/eac.py
--- a/cubicweb_saem_ref/dataimport/eac.py
+++ b/cubicweb_saem_ref/dataimport/eac.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -29,7 +29,8 @@ from lxml import etree
 
 from cubicweb.dataimport.importer import ExtEntity
 from cubes.skos import to_unicode
-from cubes.saem_ref import eactype_mapping, eacaddress_mapping, eacmaintenancetype_mapping
+
+from .. import eactype_mapping, eacaddress_mapping, eacmaintenancetype_mapping
 
 TYPE_MAPPING = eactype_mapping.copy()
 TYPE_MAPPING['human'] = u'person'
diff --git a/cubicweb_saem_ref/dataimport/seda.py b/cubicweb_saem_ref/dataimport/seda.py
--- a/cubicweb_saem_ref/dataimport/seda.py
+++ b/cubicweb_saem_ref/dataimport/seda.py
@@ -6,7 +6,7 @@ from cubicweb.dataimport.importer import
 
 from cubes.skos.sobjects import lcsv_extentities, store_skos_extentities
 
-from cubes.saem_ref.sobjects.skos import _store
+from ..sobjects.skos import _store
 
 
 def lcsv_import(cnx, store, fpath, scheme_uri):
diff --git a/cubicweb_saem_ref/entities/eac.py b/cubicweb_saem_ref/entities/eac.py
--- a/cubicweb_saem_ref/entities/eac.py
+++ b/cubicweb_saem_ref/entities/eac.py
@@ -1,4 +1,4 @@
-# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -21,7 +21,7 @@ from cubes.oaipmh import MetadataFormat
 from cubes.oaipmh.entities import RelatedEntityOAISetSpec
 from cubes.eac import entities as eac
 
-from cubes.saem_ref.entities import oai
+from . import oai
 
 
 ARECORD_METADATA_FORMATS = {
diff --git a/cubicweb_saem_ref/entities/org.py b/cubicweb_saem_ref/entities/org.py
--- a/cubicweb_saem_ref/entities/org.py
+++ b/cubicweb_saem_ref/entities/org.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -22,7 +22,7 @@ from cubicweb.entities import AnyEntity,
 
 from cubes.oaipmh.entities import ETypeOAISetSpec, RelatedEntityOAISetSpec
 
-from cubes.saem_ref.entities import oai
+from . import oai
 
 
 class Organization(AnyEntity):
diff --git a/cubicweb_saem_ref/entities/rdf.py b/cubicweb_saem_ref/entities/rdf.py
--- a/cubicweb_saem_ref/entities/rdf.py
+++ b/cubicweb_saem_ref/entities/rdf.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -20,7 +20,7 @@ from cubicweb.predicates import is_insta
 from cubes.skos import rdfio
 from cubes.skos.entities import AbstractRDFAdapter
 
-from cubes.saem_ref import permanent_url
+from .. import permanent_url
 
 
 def _register_agent_prov_mapping(reg):  # XXX move to the prov cube
diff --git a/cubicweb_saem_ref/entities/seda.py b/cubicweb_saem_ref/entities/seda.py
--- a/cubicweb_saem_ref/entities/seda.py
+++ b/cubicweb_saem_ref/entities/seda.py
@@ -1,5 +1,5 @@
 #  coding: utf-8
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -27,8 +27,8 @@ from cubes.seda.entities.custom import S
 from cubes.seda.entities.profile_generation import SEDA1XSDExport
 from cubes.seda.views import export
 
-from cubes.saem_ref import cwuri_url
-from cubes.saem_ref.entities import oai
+from .. import cwuri_url
+from . import oai
 
 
 SEDA1XSDExport.cwuri_url = staticmethod(cwuri_url)
diff --git a/cubicweb_saem_ref/entities/skos.py b/cubicweb_saem_ref/entities/skos.py
--- a/cubicweb_saem_ref/entities/skos.py
+++ b/cubicweb_saem_ref/entities/skos.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -22,7 +22,8 @@ from cubicweb.entities import fetch_conf
 
 from cubes.skos import entities as skos
 from cubes.oaipmh.entities import ETypeOAISetSpec, RelatedEntityOAISetSpec
-from cubes.saem_ref.entities import oai
+
+from . import oai
 
 
 @monkeypatch(skos)
diff --git a/cubicweb_saem_ref/hooks.py b/cubicweb_saem_ref/hooks.py
--- a/cubicweb_saem_ref/hooks.py
+++ b/cubicweb_saem_ref/hooks.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -456,8 +456,10 @@ class AuthorityRecordUsedBySetDefault(ho
 
 def registration_callback(vreg):
     vreg.register_all(globals().values(), __name__)
+
     from cubicweb.server import ON_COMMIT_ADD_RELATIONS
-    from cubes.saem_ref import PERMISSIONS_GRAPHS, mandatory_rdefs
+    from . import PERMISSIONS_GRAPHS, mandatory_rdefs
+
     # Add relations involved in a composite graph with security setup to "on
     # commit" check step.
     schema = vreg.schema
diff --git a/cubicweb_saem_ref/schema.py b/cubicweb_saem_ref/schema.py
--- a/cubicweb_saem_ref/schema.py
+++ b/cubicweb_saem_ref/schema.py
@@ -1,5 +1,5 @@
 # coding: utf-8
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -29,7 +29,8 @@ from cubes.skos.schema import ConceptSch
 from cubes.eac.schema import AuthorityRecord
 from cubes.seda.schema import simplified_profile
 from cubes.seda.schema.seda2 import SEDAArchiveTransfer
-from cubes.saem_ref import PERMISSIONS_GRAPHS, optional_relations, mandatory_rdefs
+
+from . import PERMISSIONS_GRAPHS, optional_relations, mandatory_rdefs
 
 
 def publication_permissions(cls):
diff --git a/cubicweb_saem_ref/site_cubicweb.py b/cubicweb_saem_ref/site_cubicweb.py
--- a/cubicweb_saem_ref/site_cubicweb.py
+++ b/cubicweb_saem_ref/site_cubicweb.py
@@ -130,7 +130,7 @@ def init_seda_scheme(cnx, title, _count=
 
 @monkeypatch(seda)
 def get_store(cnx):
-    from cubes.saem_ref.sobjects import SAEMMetadataGenerator
+    from .sobjects import SAEMMetadataGenerator
     metagen = SAEMMetadataGenerator(cnx, naa_what='25651')
     if cnx.repo.system_source.dbdriver == 'postgres':
         from cubicweb.dataimport.massive_store import MassiveObjectStore
diff --git a/cubicweb_saem_ref/views/__init__.py b/cubicweb_saem_ref/views/__init__.py
--- a/cubicweb_saem_ref/views/__init__.py
+++ b/cubicweb_saem_ref/views/__init__.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -34,7 +34,7 @@ from cubicweb.web.views import basecompo
 from cubes.squareui.views.basetemplates import basetemplates
 from cubes.seda.views import dropdown_button, has_rel_perm, widgets as sedawidgets
 
-from cubes.saem_ref import cwuri_url
+from .. import cwuri_url
 
 
 pvs = uicfg.primaryview_section
diff --git a/cubicweb_saem_ref/views/authorityrecord.py b/cubicweb_saem_ref/views/authorityrecord.py
--- a/cubicweb_saem_ref/views/authorityrecord.py
+++ b/cubicweb_saem_ref/views/authorityrecord.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -28,7 +28,7 @@ from cubicweb.predicates import adaptabl
 from cubicweb.web import formfields as ff, formwidgets as fw
 from cubicweb.web.views import tabs, uicfg
 
-from cubes.saem_ref import cwuri_url, user_has_authority
+from .. import cwuri_url, user_has_authority
 from . import (ImportEntityComponent, RelatedEntitiesListView, SubviewsTabView,
                RelationInfo, editlinks, external_link)
 from .widgets import JQueryIncompleteDatePicker, ConceptAutoCompleteWidget
diff --git a/cubicweb_saem_ref/views/eac.py b/cubicweb_saem_ref/views/eac.py
--- a/cubicweb_saem_ref/views/eac.py
+++ b/cubicweb_saem_ref/views/eac.py
@@ -24,7 +24,7 @@ from cubicweb.web.views import editforms
 
 from cubes.eac import views as eac
 
-from cubes.saem_ref import user_has_naa, user_has_authority
+from .. import user_has_naa, user_has_authority
 
 
 def naa_form_vocabulary(form, field):
diff --git a/cubicweb_saem_ref/views/management.py b/cubicweb_saem_ref/views/management.py
--- a/cubicweb_saem_ref/views/management.py
+++ b/cubicweb_saem_ref/views/management.py
@@ -1,4 +1,4 @@
-# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -23,7 +23,7 @@ from cubicweb.predicates import has_perm
 from cubicweb.web import component, formwidgets as fw
 from cubicweb.web.views import actions, debug, urlrewrite, uicfg
 
-from cubes.saem_ref.views import SAEMRefRewriter, AddEntityComponent
+from . import SAEMRefRewriter, AddEntityComponent
 
 
 pvs = uicfg.primaryview_section
diff --git a/cubicweb_saem_ref/views/skos.py b/cubicweb_saem_ref/views/skos.py
--- a/cubicweb_saem_ref/views/skos.py
+++ b/cubicweb_saem_ref/views/skos.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -23,7 +23,8 @@ from cubicweb.web import formwidgets as 
 from cubicweb.web.views import baseviews, tabs, treeview, uicfg, editcontroller
 
 from cubes.skos import views as skos
-from cubes.saem_ref.views import ImportEntityComponent
+
+from . import ImportEntityComponent
 
 
 afs = uicfg.autoform_section
diff --git a/cubicweb_saem_ref/views/startup.py b/cubicweb_saem_ref/views/startup.py
--- a/cubicweb_saem_ref/views/startup.py
+++ b/cubicweb_saem_ref/views/startup.py
@@ -1,4 +1,4 @@
-# copyright 2015-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -20,7 +20,7 @@ from contextlib import contextmanager
 from cubicweb import tags
 from cubicweb.web.views import baseviews, startup, uicfg
 
-from cubes.saem_ref.views import add_etype_link, import_etype_link
+from . import add_etype_link, import_etype_link
 
 
 for etype in ('AgentKind', 'ArchivalRole', 'AgentPlace',


More information about the saem-devel mailing list