Skip to content

Commit 6dd06f6

Browse files
authored
Merge pull request the-library-code#37 from mdwRepository/feature/pylint-refactoring
Proposal: Integrate Pylint the-library-code#34
2 parents c888f2d + 90f41db commit 6dd06f6

File tree

10 files changed

+694
-423
lines changed

10 files changed

+694
-423
lines changed

.github/workflows/pylint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install -r requirements.txt
21+
pip install pylint
22+
- name: Analysing the code with pylint
23+
run: |
24+
pylint $(git ls-files '*.py') --ignore-paths=^tests/.*$ --output=lint_${{ matrix.python-version }}.txt || true
25+
- name: Upload Artifact
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: lint_${{ matrix.python-version }}.txt
29+
path: lint_${{ matrix.python-version }}.txt

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[MAIN]

console.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1+
import code
2+
import os
3+
import sys
4+
15
from dspace_rest_client.client import DSpaceClient
26
# Import models as needed
37
#from dspace_rest_client.models import Community, Collection, Item, Bundle, Bitstream
4-
import code
5-
import os
68

7-
# The DSpace client will look for the same environment variables, but we can also look for them here explicitly
8-
# and as an example
9-
url = 'http://localhost:8080/server/api'
10-
if 'DSPACE_API_ENDPOINT' in os.environ:
11-
url = os.environ['DSPACE_API_ENDPOINT']
12-
username = '[email protected]'
13-
if 'DSPACE_API_USERNAME' in os.environ:
14-
username = os.environ['DSPACE_API_USERNAME']
15-
password = 'password'
16-
if 'DSPACE_API_PASSWORD' in os.environ:
17-
password = os.environ['DSPACE_API_PASSWORD']
9+
DEFAULT_URL = 'http://localhost:8080/server/api'
10+
DEFAULT_USERNAME = '[email protected]'
11+
DEFAULT_PASSWORD = 'password'
12+
13+
# Configuration from environment variables
14+
URL = os.environ.get('DSPACE_API_ENDPOINT', DEFAULT_URL)
15+
USERNAME = os.environ.get('DSPACE_API_USERNAME', DEFAULT_USERNAME)
16+
PASSWORD = os.environ.get('DSPACE_API_PASSWORD', DEFAULT_PASSWORD)
1817

1918
# Instantiate DSpace client
20-
d = DSpaceClient(api_endpoint=url, username=username, password=password)
19+
d = DSpaceClient(api_endpoint=URL, username=USERNAME, password=PASSWORD)
2120

2221
# Authenticate against the DSpace client
2322
authenticated = d.authenticate()
2423
if not authenticated:
25-
print(f'Error logging in! Giving up.')
26-
exit(1)
24+
print('Error logging in! Giving up.')
25+
sys.exit(1)
2726

2827
code.interact(local=locals())

0 commit comments

Comments
 (0)