This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added utils thing to take out some of the messy per server settings c…
…ode. Finished processing settings in weaver
- Loading branch information
j.c.sackett
committed
Jul 17, 2009
1 parent
71c1b69
commit c046297
Showing
2 changed files
with
38 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#Set of utilities for weaver. | ||
|
||
class SettingsError(Exception): | ||
pass | ||
|
||
def get_setting(setting_name, setting_mod, transform=lambda x: x): | ||
setting = getattr(setting_mod, setting_name) | ||
if type(setting) == str: | ||
return transform(setting) | ||
elif type(setting) == tuple: | ||
setting = dict( | ||
staging=transform(setting[0]), | ||
internal=transform(setting[1]), | ||
production=transform(setting[2]), | ||
) | ||
return setting | ||
else: | ||
raise SettingsError('Settings must be one of: str, tuple') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters