r81162 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81161‎ | r81162 | r81163 >
Date:20:51, 28 January 2011
Author:diederik
Status:deferred
Tags:
Comment:
A little bit of cleaning up.
Modified paths:
  • /trunk/tools/editor_trends/classes/exceptions.py (modified) (history)
  • /trunk/tools/editor_trends/classes/languages.py (modified) (history)
  • /trunk/tools/editor_trends/classes/projects.py (modified) (history)
  • /trunk/tools/editor_trends/classes/runtime_settings.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/classes/projects.py
@@ -40,7 +40,8 @@
4141 lang = lnc.init_languages[lang]
4242 if lang in self.valid_languages:
4343 if output == 'parser':
44 - choices.append(lnc.languages.get(lang, 'Unknown language'))
 44+ lang = lnc.languages.get(lang, 'Unknown language')
 45+ choices.append(lang.name)
4546 elif output == 'django':
4647 lang = lnc.languages.get(lang, languages.Language('Unknown language', lang, None))
4748 choices.append((lang.code, lang.name))
Index: trunk/tools/editor_trends/classes/exceptions.py
@@ -61,3 +61,11 @@
6262 def __str__(self):
6363 return 'There is no JSON encoder called %s, please make sure that you \
6464 entered the right name' % self.func
 65+
 66+class NotYetImplementedError(Error):
 67+ def __init__(self, func):
 68+ self.func = func
 69+
 70+ def __str__(self):
 71+ return '''%s has not yet been implemented, update your installation from
 72+ subversion or contact diederik van liere.''' % self.func.func_name
Index: trunk/tools/editor_trends/classes/runtime_settings.py
@@ -54,8 +54,8 @@
5555 self.hash = self.secs_since_epoch()
5656 self.base_location = self.settings.input_location if \
5757 self.settings.input_location != None else self.get_value('location')
58 - self.update_project_settings()
59 - self.update_language_settings()
 58+ self.project = self.update_project_settings()
 59+ self.language = self.update_language_settings()
6060
6161 self.targets = self.split_keywords(self.get_value('charts'))
6262 self.keywords = self.split_keywords(self.get_value('keywords'))
@@ -167,18 +167,23 @@
168168 lnc = languages.LanguageContainer()
169169 default = lnc.languages[lnc.default]
170170 if lang != default.name:
171 - lang = lnc.get_language(lang)
 171+ lang = lnc.get_language(lang, code=False)
172172 return lang
 173+ else:
 174+ return default
173175
174176 def update_project_settings(self):
175177 '''
176178 Determine the project to be analyzed, default is Wikipedia
177179 '''
 180+ default = self.project
178181 proj = self.get_value('project')
179182 if proj != 'wiki':
180183 pc = projects.ProjectContainer()
181184 proj = pc.get_project(proj)
182185 return proj
 186+ else:
 187+ return default
183188
184189 def get_projectname(self):
185190 '''
Index: trunk/tools/editor_trends/classes/languages.py
@@ -29,7 +29,7 @@
3030 self.default = default
3131
3232 def __repr__(self):
33 - return '%s - %s' % (self.code, self.name)
 33+ return u'%s - %s' % (self.code, self.name)
3434
3535 def show_languages(self, settings, project, startswith=None):
3636 if startswith != None:
@@ -642,8 +642,10 @@
643643 def __repr__(self):
644644 return 'contains %s languages' % (len(self.languages))
645645
646 - def get_language(self, code):
647 - return self.languages.get(code, None)
 646+ def get_language(self, value, code=True):
 647+ if not code:
 648+ value = self.init_languages[value]
 649+ return self.languages.get(value, None)
648650
649651 def determine_default_language(self):
650652 '''

Status & tagging log