| Total Complexity | 2 | 
| Total Lines | 42 | 
| Duplicated Lines | 57.14 % | 
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | import logging  | 
            ||
| 2 | |||
| 3 | import requests  | 
            ||
| 4 | from atramhasis import skos  | 
            ||
| 5 | from cachecontrol import CacheControl  | 
            ||
| 6 | from cachecontrol.heuristics import ExpiresAfter  | 
            ||
| 7 | from skosprovider.registry import Registry  | 
            ||
| 8 | from skosprovider_getty.providers import AATProvider  | 
            ||
| 9 | from skosprovider_getty.providers import TGNProvider  | 
            ||
| 10 | |||
| 11 | log = logging.getLogger(__name__)  | 
            ||
| 12 | LICENSES = [  | 
            ||
| 13 | 'https://creativecommons.org/licenses/by/4.0/',  | 
            ||
| 14 | 'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'  | 
            ||
| 15 | ]  | 
            ||
| 16 | |||
| 17 | |||
| 18 | View Code Duplication | def create_registry(request):  | 
            |
| 19 | try:  | 
            ||
| 20 | registry = Registry(instance_scope='threaded_thread')  | 
            ||
| 21 | |||
| 22 | getty_session = CacheControl(requests.Session(), heuristic=ExpiresAfter(weeks=1))  | 
            ||
| 23 | |||
| 24 | aat = AATProvider(  | 
            ||
| 25 |             {'id': 'AAT', 'subject': ['external']}, | 
            ||
| 26 | session=getty_session  | 
            ||
| 27 | )  | 
            ||
| 28 | |||
| 29 | tgn = TGNProvider(  | 
            ||
| 30 |             {'id': 'TGN', 'subject': ['external']}, | 
            ||
| 31 | session=getty_session  | 
            ||
| 32 | )  | 
            ||
| 33 | |||
| 34 | registry.register_provider(aat)  | 
            ||
| 35 | registry.register_provider(tgn)  | 
            ||
| 36 | skos.register_providers_from_db(registry, request.db)  | 
            ||
| 37 | |||
| 38 | return registry  | 
            ||
| 39 | except AttributeError:  | 
            ||
| 40 |         log.exception("Attribute error during creation of Registry.") | 
            ||
| 41 | raise  | 
            ||
| 42 |