Skip to content

Commit

Permalink
Added config file copying to init
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter Senft-Grupp committed Mar 21, 2016
1 parent 8dedeca commit 957b2b5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion bragly/brag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import arrow
import bragly.persist as persist
import os
import pkg_resources

PERSIST_CHOICES = list(persist.MECHANISMS.keys())

Expand Down Expand Up @@ -109,4 +110,23 @@ def init(mechanism):
print('success', flush=True)
print('OK', flush=True)

return ['Initialization finished']
print('Getting example configuration for mechanism: {}...'.format(
mechanism), end='', flush=True)

config_example = pkg_resources.resource_filename(
'bragly',
'config_examples/config-{}.ini'.format(mechanism)
)

with open(config_example, 'r') as f:
config_data = f.read()
print('OK')

config_file_path = os.path.join(directory, 'config.ini')

print('Writing to {}...'.format(config_file_path), end='', flush=True)
with open(config_file_path, 'w') as f:
f.write(config_data)
print('OK')

return ['Initialization finished']

0 comments on commit 957b2b5

Please sign in to comment.