Skip to content

Commit

Permalink
Create new django app matchcodeio #224
Browse files Browse the repository at this point in the history
    * Add scancodeio under extra_requires

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Dec 13, 2023
1 parent fa6b38e commit 4659ccb
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
graft src
graft clearcode
graft clearindex
graft matchcode
graft minecode
graft packagedb
graft purldb

include *.LICENSE
include NOTICE
Expand Down
Empty file added matchcodeio/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions matchcodeio/dbrouter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# purldb is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/purldb for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#


class PackageDBReadOnlyRouter(object):
app_labels = [
'clearcode',
'clearindex',
'minecode',
'matchcode',
'packagedb',
]

def db_for_read(self, model, **hints):
if model._meta.app_label in self.app_labels:
return 'packagedb'
return None

def db_for_write(self, model, **hints):
return None

def allow_relation(self, obj1, obj2, **hints):
return None

def allow_migrate(self, db, app_label, model_name=None, **hints):
return None
35 changes: 35 additions & 0 deletions matchcodeio/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# purldb is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/purldb for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

from scancodeio.settings import *


INSTALLED_APPS += [
"packagedb",
"matchcode",
]


# Database

DATABASES.update(
{
'packagedb': {
'ENGINE': env.str('PACKAGEDB_DB_ENGINE', 'django.db.backends.postgresql'),
'HOST': env.str('PACKAGEDB_DB_HOST', 'localhost'),
'NAME': env.str('PACKAGEDB_DB_NAME', 'packagedb'),
'USER': env.str('PACKAGEDB_DB_USER', 'packagedb'),
'PASSWORD': env.str('PACKAGEDB_DB_PASSWORD', 'packagedb'),
'PORT': env.str('PACKAGEDB_DB_PORT', '5432'),
'ATOMIC_REQUESTS': True,
}
}
)

DATABASE_ROUTERS = ["matchcodeio.dbrouter.PackageDBReadOnlyRouter",]
25 changes: 25 additions & 0 deletions matchcodeio/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# purldb is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/purldb for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

"""
WSGI config for MatchCode.io.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "matchcodeio.settings")

application = get_wsgi_application()
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ python_requires = >=3.8
where = .

[options.extras_require]
matchcodeio =
scancodeio

testing =
pytest >= 6, != 7.0.0
pytest-xdist >= 2
pytest-django
aboutcode-toolkit >= 6.0.0
black
mock
scancodeio

docs =
Sphinx==5.0.2
Expand All @@ -81,3 +85,6 @@ docs =
[options.entry_points]
console_scripts =
purldb = purldb:command_line

scancodeio_pipelines =
scan_and_fingerprint_package = matchcode_toolkit.pipelines.scan_and_fingerprint_package:ScanAndFingerprintPackage

0 comments on commit 4659ccb

Please sign in to comment.