Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #55 from dbrgn/issue55

Fixed crash related to configuration defaults
  • Loading branch information...
commit 11aae1ad7ba8244dc93495f531243db7dcdd0561 2 parents a5a4d60 + 435caa9
@dbrgn authored
Showing with 14 additions and 6 deletions.
  1. +14 −6 orochi/client.py
View
20 orochi/client.py
@@ -53,7 +53,11 @@ class ConfigFile(object):
each write."""
DEFAULT_CONFIG_KEYS = ['mplayer_extra_arguments', 'username', 'password',
- 'autologin', 'results_per_page', 'results_sorting']
+ 'autologin', 'results_per_page', 'results_sorting']
+ DEFAULTS = {
+ 'results_per_page': 10,
+ 'results_sorting': 'hot',
+ }
def __init__(self, filename=None):
if not filename:
@@ -143,13 +147,17 @@ def preloop(self):
self.total_pages = None
self.query_type = None
- if not self.config['results_per_page']:
- self.config['results_per_page'] = self._results_per_page = 10
- elif not self.config['results_sorting']:
- self.config['results_sorting'] = self._results_sorting = 'hot'
- else:
+ # Set some config defaults
+ if self.config['results_per_page']:
self._results_per_page = self.config['results_per_page']
+ else:
+ default_value = ConfigFile.DEFAULTS.get('results_per_page')
+ self.config['results_per_page'] = self._results_per_page = default_value
+ if self.config['results_sorting']:
self._results_sorting = self.config['results_sorting']
+ else:
+ default_value = ConfigFile.DEFAULTS.get('results_sorting')
+ self.config['results_sorting'] = self._results_sorting = default_value
# Try to login if autologin is on.
if self.config['username'] and self.config['password'] and self.config['autologin']:
Please sign in to comment.
Something went wrong with that request. Please try again.