Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_helper_files
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
common_helper_files
Commits
515920e6
Commit
515920e6
authored
Apr 27, 2017
by
Timm Behner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'config_helper'
parents
cc7177f4
622d80b0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletions
+51
-1
LICENSE
LICENSE
+21
-0
__init__.py
common_helper_files/__init__.py
+3
-1
config_functions.py
common_helper_files/config_functions.py
+27
-0
No files found.
LICENSE
0 → 100644
View file @
515920e6
MIT License
Copyright (c) 2016 MASS Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
common_helper_files/__init__.py
View file @
515920e6
...
@@ -4,6 +4,7 @@ from .file_functions import read_in_chunks, get_directory_for_filename, create_d
...
@@ -4,6 +4,7 @@ from .file_functions import read_in_chunks, get_directory_for_filename, create_d
from
.git_functions
import
get_version_string_from_git
from
.git_functions
import
get_version_string_from_git
from
.hash_functions
import
md5sum
from
.hash_functions
import
md5sum
from
.fail_safe_file_operations
import
get_binary_from_file
,
write_binary_to_file
,
get_safe_name
,
delete_file
,
get_files_in_dir
from
.fail_safe_file_operations
import
get_binary_from_file
,
write_binary_to_file
,
get_safe_name
,
delete_file
,
get_files_in_dir
from
.config_functions
import
update_config_from_env
__all__
=
[
__all__
=
[
'get_directory_for_filename'
,
'get_directory_for_filename'
,
...
@@ -16,5 +17,6 @@ __all__ = [
...
@@ -16,5 +17,6 @@ __all__ = [
'write_binary_to_file'
,
'write_binary_to_file'
,
'get_safe_name'
,
'get_safe_name'
,
'delete_file'
,
'delete_file'
,
'get_files_in_dir'
'get_files_in_dir'
,
'update_config_from_env'
,
]
]
common_helper_files/config_functions.py
0 → 100644
View file @
515920e6
"""Helper functions for configuration files.
"""
import
os
import
logging
log
=
logging
.
getLogger
(
__name__
)
def
update_config_from_env
(
config
):
""" Update configuration fields in config from environment variables.
The environment variable names are expected to be of the form, that the
section name and the variable name are seperated by a dubble underscore,
e.g.
SECTION_NAME__VARIABLE_NAME
"""
for
key
,
val
in
os
.
environ
.
items
():
if
'__'
in
key
:
section
,
section_key
=
key
.
lower
()
.
split
(
'__'
)
try
:
config
[
section
.
capitalize
()][
section_key
]
=
val
except
KeyError
:
log
.
error
(
'No section {} or value {} found.'
.
format
(
section
.
capitalize
(),
section_key
))
return
config
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment