diff options
| author | Ade Lee <alee@redhat.com> | 2017-03-15 23:05:07 -0400 |
|---|---|---|
| committer | Ade Lee <alee@redhat.com> | 2017-03-15 23:05:07 -0400 |
| commit | 080f3d2a8bf36be407c79ddd71381450c8667b2e (patch) | |
| tree | 58594f9c45e88c882579d9f6638ff6639e506729 /base/common/python/pki/util.py | |
| parent | 764a17314e81cade8bf1192739b5a2fad11d18bd (diff) | |
| parent | 07135b5906f97a8c68148a07484e63d6896f410b (diff) | |
| download | pki-080f3d2a8bf36be407c79ddd71381450c8667b2e.tar.gz pki-080f3d2a8bf36be407c79ddd71381450c8667b2e.tar.xz pki-080f3d2a8bf36be407c79ddd71381450c8667b2e.zip | |
Merge branch 'master' of github.com:dogtagpki/pki
Diffstat (limited to 'base/common/python/pki/util.py')
| -rw-r--r-- | base/common/python/pki/util.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/base/common/python/pki/util.py b/base/common/python/pki/util.py index 8a75ff6f5..68118f439 100644 --- a/base/common/python/pki/util.py +++ b/base/common/python/pki/util.py @@ -143,6 +143,39 @@ def customize_file(input_file, output_file, params): outfile.write(line) +def load_properties(filename, properties): + + with open(filename) as f: + + lines = f.read().splitlines() + + for index, line in enumerate(lines): + + line = line.strip() + + if not line or line.startswith('#'): + continue + + parts = line.split('=', 1) + + if len(parts) < 2: + raise Exception('Missing delimiter in %s line %d' % + (filename, index + 1)) + + name = parts[0].strip() + value = parts[1].strip() + properties[name] = value + + +def store_properties(filename, properties): + + with open(filename, 'w') as f: + + for name, value in properties.items(): + line = '%s=%s\n' % (name, value) + f.write(line) + + def copytree(src, dst, symlinks=False, ignore=None): """ Recursively copy a directory tree using copy2(). |
