Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Reorder ConfigValue parser arguments for standalone use.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode committed Jun 12, 2012
1 parent 47e5594 commit 3c8160a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions r2/r2/lib/app_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@

class ConfigValue(object):
@staticmethod
def int(k, v, data):
def int(v, key=None, data=None):
return int(v)

@staticmethod
def float(k, v, data):
def float(v, key=None, data=None):
return float(v)

@staticmethod
def bool(k, v, data):
def bool(v, key=None, data=None):
return (v.lower() == 'true') if v else None

@staticmethod
def tuple(k, v, data):
def tuple(v, key=None, data=None):
return tuple(ConfigValue.to_iter(v))

@staticmethod
def choice(k, v, data):
def choice(v, key, data):
if v not in data:
raise ValueError("Unknown option for %r: %r not in %r" % (k, v, data))
raise ValueError("Unknown option for %r: %r not in %r" % (key, v, data))
return data[v]

@staticmethod
Expand Down Expand Up @@ -92,7 +92,7 @@ def _update_values(self, keys):
value = self.raw_data[key]
if key in self.config_keys:
parser, extra_data = self.config_keys[key]
value = parser(key, value, extra_data)
value = parser(value, key, extra_data)
self[key] = value

class Globals(object):
Expand Down

0 comments on commit 3c8160a

Please sign in to comment.