mirror of https://github.com/searxng/searxng.git
[mod] get rid of searx/brand.py
Removes module searx/brand.py and creates a namespace at searx.brand. This patch is a first 'proof of concept'. Later we can decide to remove the brand namespace entirely or not. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
9485179064
commit
9e53470b4c
|
@ -123,9 +123,9 @@ docker_build() {
|
||||||
SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
|
SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
|
||||||
|
|
||||||
# add the suffix "-dirty" if the repository has uncommited change
|
# add the suffix "-dirty" if the repository has uncommited change
|
||||||
# /!\ HACK for searx/searx: ignore searx/brand.py and utils/brand.env
|
# /!\ HACK for searx/searx: ignore utils/brand.env
|
||||||
git update-index -q --refresh
|
git update-index -q --refresh
|
||||||
if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'searx/brand.py' | grep -v 'utils/brand.env')" ]; then
|
if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
|
||||||
SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
|
SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -60,3 +60,49 @@ if 'SEARX_SECRET' in environ:
|
||||||
settings['server']['secret_key'] = environ['SEARX_SECRET']
|
settings['server']['secret_key'] = environ['SEARX_SECRET']
|
||||||
if 'SEARX_BIND_ADDRESS' in environ:
|
if 'SEARX_BIND_ADDRESS' in environ:
|
||||||
settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
|
settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
|
||||||
|
|
||||||
|
|
||||||
|
class _brand_namespace:
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_val(cls, group, name, default=''):
|
||||||
|
return settings[group].get(name, False) or ''
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SEARX_URL(self):
|
||||||
|
return self.get_val('server', 'base_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def GIT_URL(self):
|
||||||
|
return self.get_val('general', 'git_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def GIT_BRANCH(self):
|
||||||
|
return self.get_val('general', 'git_branch')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ISSUE_URL(self):
|
||||||
|
return self.get_val('general', 'issue_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def DOCS_URL(self):
|
||||||
|
return self.get_val('general', 'docs_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PUBLIC_INSTANCES(self):
|
||||||
|
return self.get_val('general', 'public_instances')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def CONTACT_URL(self):
|
||||||
|
return self.get_val('general', 'contact_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def WIKI_URL(self):
|
||||||
|
return self.get_val('general', 'wiki_url')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TWITTER_URL(self):
|
||||||
|
return self.get_val('general', 'twitter_url')
|
||||||
|
|
||||||
|
|
||||||
|
brand = _brand_namespace()
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
SEARX_URL = ''
|
|
||||||
GIT_URL = 'https://github.com/searx/searx'
|
|
||||||
GIT_BRANCH = 'master'
|
|
||||||
ISSUE_URL = 'https://github.com/searx/searx/issues'
|
|
||||||
DOCS_URL = 'https://searx.github.io/searx'
|
|
||||||
PUBLIC_INSTANCES = 'https://searx.space'
|
|
||||||
CONTACT_URL = ''
|
|
||||||
WIKI_URL = 'https://github.com/searx/searx/wiki'
|
|
||||||
TWITTER_URL = 'https://twitter.com/Searx_engine'
|
|
6
setup.py
6
setup.py
|
@ -7,10 +7,8 @@ from setuptools import find_packages
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# required to load VERSION_STRING constant
|
from searx.version import VERSION_STRING
|
||||||
sys.path.insert(0, './searx')
|
from searx import brand
|
||||||
from version import VERSION_STRING
|
|
||||||
import brand
|
|
||||||
|
|
||||||
with open('README.rst', encoding='utf-8') as f:
|
with open('README.rst', encoding='utf-8') as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
|
@ -8,35 +8,23 @@ from os.path import realpath, dirname, join, sep
|
||||||
repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
|
repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
|
||||||
sys.path.insert(0, repo_root)
|
sys.path.insert(0, repo_root)
|
||||||
|
|
||||||
from searx.settings_loader import load_settings
|
from searx import brand
|
||||||
|
|
||||||
settings, settings_load_message = load_settings()
|
|
||||||
print(settings_load_message)
|
|
||||||
|
|
||||||
brand_env = 'utils' + sep + 'brand.env'
|
|
||||||
brand_py = 'searx' + sep + 'brand.py'
|
|
||||||
|
|
||||||
def get_val(group, name, default=''):
|
|
||||||
return settings[group].get(name, False) or ''
|
|
||||||
|
|
||||||
name_val = [
|
name_val = [
|
||||||
('SEARX_URL' , get_val('server', 'base_url')),
|
('SEARX_URL' , brand.SEARX_URL),
|
||||||
('GIT_URL' , get_val('general','git_url')),
|
('GIT_URL' , brand.GIT_URL),
|
||||||
('GIT_BRANCH' , get_val('general','git_branch')),
|
('GIT_BRANCH' , brand.GIT_BRANCH),
|
||||||
('ISSUE_URL' , get_val('general','issue_url')),
|
('ISSUE_URL' , brand.ISSUE_URL),
|
||||||
('DOCS_URL' , get_val('general','docs_url')),
|
('DOCS_URL' , brand.DOCS_URL),
|
||||||
('PUBLIC_INSTANCES' , get_val('general','public_instances')),
|
('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
|
||||||
('CONTACT_URL' , get_val('general','contact_url')),
|
('CONTACT_URL' , brand.CONTACT_URL),
|
||||||
('WIKI_URL' , get_val('general','wiki_url')),
|
('WIKI_URL' , brand.WIKI_URL),
|
||||||
('TWITTER_URL' , get_val('general','twitter_url')),
|
('TWITTER_URL' , brand.TWITTER_URL),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
brand_env = 'utils' + sep + 'brand.env'
|
||||||
|
|
||||||
print('build %s' % brand_env)
|
print('build %s' % brand_env)
|
||||||
with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
|
with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
|
||||||
for name, val in name_val:
|
for name, val in name_val:
|
||||||
print("export %s='%s'" % (name, val), file=f)
|
print("export %s='%s'" % (name, val), file=f)
|
||||||
|
|
||||||
print('build %s' % brand_py)
|
|
||||||
with open(repo_root + sep + brand_py, 'w', encoding='utf-8') as f:
|
|
||||||
for name, val in name_val:
|
|
||||||
print("%s = '%s'" % (name, val), file=f)
|
|
||||||
|
|
Loading…
Reference in New Issue