Skip to content

Commit

Permalink
Merge pull request #34 from Helmholtz-UFZ/develop
Browse files Browse the repository at this point in the history
Merge UFZ Develop branch
  • Loading branch information
Normo authored Nov 20, 2023
2 parents c54efbb + c6055a7 commit 58bdaf2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"

- package-ecosystem: "pip"
directory: "/"
schedule:
# Check for updates to pip packages every weekday
interval: "daily"
ignore:
- dependency-name: "python"
update-types: ["version-update:semver-major"]

...
10 changes: 0 additions & 10 deletions .gitmodules

This file was deleted.

48 changes: 26 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,28 @@
"""

import argparse
import os
import re
import asyncio
import base64
import glob
import logging
import base64
import magic
import os
import re

import yaml
import jwt

import asyncio
import magic
import yaml
from postgrest import APIError, AsyncPostgrestClient

from mdparser.mdparser import SvHtmlParser


VERBOSE = False
DELETE_SPOTLIGHTS = False
UPDATE_IMPRINT = False
POSTGREST_URL = os.environ.get("POSTGREST_URL")
PGRST_JWT_SECRET = os.environ.get("PGRST_JWT_SECRET")
JWT_PAYLOAD = {"role": "rsd_admin"}
JWT_ALGORITHM = "HS256"
SPOTLIGHTS_DIR = "hifis.net/_spotlights"
SPOTLIGHTS_DIR = "software-descriptions/software/rendered"

ORGANISATIONS = {
"Helmholtz Centre for Environmental Research (UFZ)": {
Expand Down Expand Up @@ -81,8 +79,8 @@
},
"German Cancer Research Center (DKFZ)": {
"logo": "dkfz.svg",
"ror": "04cdgtt98"
}
"ror": "04cdgtt98",
},
}
MISSING_LOGOS = []

Expand Down Expand Up @@ -152,10 +150,18 @@ def get_spotlights():


def name_to_slug(name):
remove_chars = name.replace(" ", "-").replace("+", "").lower()
remove_chars = name.lower()

replacements = [
(r"\s+", "-"), # replace whitespaces
(r"[^A-Za-z0-9_ ]+", ""), # remove non-alphanumeric chars
(r"\-+", "-"), # remove multiple '-'
]

# remove multiple '-'
return re.sub(r"\-+", "-", remove_chars)
for pattern, replace in replacements:
remove_chars = re.sub(pattern, replace, remove_chars)

return remove_chars


def org_name_to_slug(name):
Expand Down Expand Up @@ -481,7 +487,7 @@ async def organisation_has_logo(client, org_id) -> bool:
.eq("id", org_id)
.execute()
)
if len(res.data) == 1 and res.data[0]['logo_id'] is not None:
if len(res.data) == 1 and res.data[0]["logo_id"] is not None:
return True
else:
return False
Expand All @@ -503,7 +509,9 @@ async def add_organisations(client, spotlight):
logging.info("Add organisations for %s", name)

for org in orgs:
org_id = await get_organisation_id_by_ror(client, ORGANISATIONS.get(org).get("ror"))
org_id = await get_organisation_id_by_ror(
client, ORGANISATIONS.get(org).get("ror")
)

if org_id is None:
logging.info("Adding organisation %s" % org)
Expand Down Expand Up @@ -540,13 +548,9 @@ async def add_organisations(client, spotlight):
"data": logo_base64,
"mime_type": mime_type,
}
res_img = (
await client.from_("image")
.insert(logo_data)
.execute()
)
res_img = await client.from_("image").insert(logo_data).execute()
logging.info(res_img.data)
logo_id = res_img.data[0]['id']
logo_id = res_img.data[0]["id"]
logging.info("Uploaded logo %s" % logo_filename)
res_org = (
await client.from_("organisation")
Expand Down

0 comments on commit 58bdaf2

Please sign in to comment.