mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 22:12:15 +00:00
work
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
@@ -28,7 +29,7 @@ class Configuration:
|
||||
repo_root = Path(__file__).parent.parent.parent.parent
|
||||
ofm_config_dir = repo_root / 'config'
|
||||
|
||||
jsonc_config = json5.loads((ofm_config_dir / 'config.jsonc').read_text())
|
||||
json_config = json.loads((ofm_config_dir / 'config.json').read_text())
|
||||
|
||||
deployed_versions_dir = ofm_config_dir / 'deployed_versions'
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ def write_nginx_config():
|
||||
for file in config.nginx_certs_dir.glob('ofm-*'):
|
||||
file.unlink()
|
||||
|
||||
conf = config.jsonc_config
|
||||
conf = config.json_config
|
||||
|
||||
curl_help_lines = []
|
||||
|
||||
@@ -40,12 +40,9 @@ def write_nginx_config():
|
||||
|
||||
|
||||
def process_domain(domain_data):
|
||||
domain_slug = slugify(domain_data['domain'], separator='_')
|
||||
domain_data['slug'] = domain_slug
|
||||
|
||||
if domain_data['cert'] == 'upload':
|
||||
domain_data['cert_file'] = config.nginx_certs_dir / f'{domain_slug}.cert'
|
||||
domain_data['key_file'] = config.nginx_certs_dir / f'{domain_slug}.key'
|
||||
domain_data['cert_file'] = config.nginx_certs_dir / f'{domain_data["slug"]}.cert'
|
||||
domain_data['key_file'] = config.nginx_certs_dir / f'{domain_data["slug"]}.key'
|
||||
|
||||
if not domain_data['cert_file'].is_file() or not domain_data['key_file'].is_file():
|
||||
sys.exit(
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
|
||||
# Pre-compiled patterns for better performance
|
||||
_RE_INVALID = re.compile(r'[^a-z0-9_-]+')
|
||||
_RE_SEPARATORS = re.compile(r'[-_]+')
|
||||
|
||||
|
||||
def slugify(
|
||||
value: str | bytes | int | float | None,
|
||||
*,
|
||||
separator: str = '-',
|
||||
) -> str:
|
||||
if value in (None, ''):
|
||||
return ''
|
||||
|
||||
if separator not in ('-', '_'):
|
||||
raise ValueError(f"separator must be '-' or '_', got {repr(separator)}")
|
||||
|
||||
# 1. Normalize value to string
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode('utf-8', 'ignore')
|
||||
else:
|
||||
value = str(value)
|
||||
|
||||
# 2. Unicode → ASCII, then lowercase
|
||||
value = unicodedata.normalize('NFKD', value)
|
||||
value = value.encode('ascii', 'ignore').decode('ascii').lower()
|
||||
|
||||
# 3. Replace invalid characters with separator
|
||||
value = _RE_INVALID.sub(separator, value)
|
||||
|
||||
# 4. Collapse multiple separators
|
||||
value = _RE_SEPARATORS.sub(separator, value)
|
||||
|
||||
# 5. Strip separators from edges
|
||||
value = value.strip('-_')
|
||||
|
||||
return value
|
||||
@@ -5,7 +5,6 @@ requirements = [
|
||||
'click',
|
||||
'pycurl',
|
||||
'requests',
|
||||
'json5',
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user