Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common-config
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
id
eigenservice
common-config
Commits
dd41834f
Commit
dd41834f
authored
1 year ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Fix error in readme, remove mentions of eigenservice in help)
parent
10861a1c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+5
-6
5 additions, 6 deletions
README.md
common_config/common.py
+10
-9
10 additions, 9 deletions
common_config/common.py
pyproject.toml
+2
-2
2 additions, 2 deletions
pyproject.toml
with
17 additions
and
17 deletions
README.md
+
5
−
6
View file @
dd41834f
# common-config
This is a common configuration library for
eigen
service
This is a common configuration library for
python based
service
s
Add this dependency to your application e.g. using poetry
(ssh-add so you don't have to type the ssh-password over and over)
:
Add this dependency to your application e.g. using poetry:
```
bash
ssh-add
poetry add git+ssh://git@code.hfbk.net:4242/id/eigenservice/common-config.git
-vvv
poetry add git+https://code.hfbk.net/id/eigenservice/common-config.git
```
When something changes update it like this:
...
...
@@ -25,7 +24,7 @@ Then in the application use something like this as a starting point:
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import
common_config
from
common_config
import
initialize_config
,
read_
settings
,
main
from
common_config
import
initialize_config
,
read_
config
# Name of this application, used in directory names, etc
APPLICATION_NAME
=
"
my_application
"
...
...
@@ -48,7 +47,7 @@ common_config.common.DEFAULT_CONFIG = DEFAULT_CONFIG
if
__name__
==
"
__main__
"
:
main
()
common_config
.
main
()
```
If people now run that file, they will get an interactive configuration-tool
...
...
This diff is collapsed.
Click to expand it.
common_config/common.py
+
10
−
9
View file @
dd41834f
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
inspect
import
os
,
getpass
,
sys
import
subprocess
import
os
import
sys
import
getpass
import
logging
import
toml
from
pathlib
import
Path
...
...
@@ -38,10 +39,10 @@ def get_config_directories() -> List[dict]:
Existence of the directories is _not_ checked
"""
# Generate a etc directory (
usually
/etc/
eigen
service)
# Generate a etc directory (
e.g.
/etc/
my_
service
_name
)
etc_directory
=
f
"
/etc/
{
APPLICATION_NAME
}
"
# Get the default config dir (
usually
/home/user/.config/
eigen
service)
# Get the default config dir (
e.g.
/home/user/.config/
my_
service
_name
)
default_config_home
=
f
"
{
get_home
()
}
/.config/
{
APPLICATION_NAME
}
"
# Unless the XDG_CONFIG_HOME environment variable has been set, then use this instead
...
...
@@ -380,8 +381,8 @@ def create_config():
"""
helptext
=
f
"""
Configs are read from the following directories (later overrides earlier):
1. DEFAULT_CONFIG (use config default to inspect)
2. /etc/
eigenservice
/*
{
SUFFIX
}
.toml (in alphabetical order)
3. $XDG_CONFIG_HOME/
eigenservice
/*
{
SUFFIX
}
.toml (in alphabetical order)
2. /etc/
{
APPLICATION_NAME
}
/*
{
SUFFIX
}
.toml (in alphabetical order)
3. $XDG_CONFIG_HOME/
{
APPLICATION_NAME
}
/*
{
SUFFIX
}
.toml (in alphabetical order)
4. $EIGENSERVICE_CONFIG_DIR/*
{
SUFFIX
}
.toml (in alphabetical order)
5. $EIGENSERVICE_CONFIG_PATH (final override)
"""
...
...
@@ -509,12 +510,12 @@ def print_help():
"""
helptext
=
f
"""
=========
{
APPLICATION_NAME
.
upper
()
}
CONFIG (
{
SUFFIX
.
upper
()
}
) =========
Helper tool for managing and installing a
eigenservice
config.
Helper tool for managing and installing a
{
APPLICATION_NAME
}
config.
Configs are read from the following directories (later overrides earlier):
1. DEFAULT_CONFIG (see below)
2. /etc/
eigenservice
/*
{
SUFFIX
}
.toml (in alphabetical order)
3. $XDG_CONFIG_HOME/
eigenservice
/*
{
SUFFIX
}
.toml (in alphabetical order)
2. /etc/
{
APPLICATION_NAME
}
/*
{
SUFFIX
}
.toml (in alphabetical order)
3. $XDG_CONFIG_HOME/
{
APPLICATION_NAME
}
/*
{
SUFFIX
}
.toml (in alphabetical order)
4. $EIGENSERVICE_CONFIG_DIR/*
{
SUFFIX
}
.toml (in alphabetical order)
5. $EIGENSERVICE_CONFIG_PATH (final override)
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
2
−
2
View file @
dd41834f
[tool.poetry]
name
=
"common-config"
version
=
"0.1.1
8
"
description
=
"A config library for
eigen
service"
version
=
"0.1.1
9
"
description
=
"A config library for
python based
service
s
"
authors
=
[
"David Huss <dh@atoav.com>"
]
[tool.poetry.dependencies]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment