Changeset 918171b


Ignore:
Timestamp:
04/15/12 20:50:07 (2 years ago)
Author:
Martin Kolman <martin.kolman@…>
Branches:
master
Children:
c484fad
Parents:
11ef0cd
git-author:
Martin Kolman <martin.kolman@…> (04/15/12 20:50:07)
git-committer:
Martin Kolman <martin.kolman@…> (04/15/12 20:50:07)
Message:

spellcheck, documentation update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modrana.py

    r7f6b0e4 r918171b  
    22# -*- coding: utf-8 -*- 
    33#---------------------------------------------------------------------------- 
    4 # Rana main GUI.  Displays maps, for use on a mobile device 
     4# modRana main GUI.  Displays maps & much more, for use on a mobile device. 
    55# 
    66# Controls: 
    7 #   * click on the overlay text to change fields displayed 
     7# Start by clicking on the main menu icon. 
    88#---------------------------------------------------------------------------- 
    99# Copyright 2007-2008, Oliver White 
     
    5252def createFolderPath(newPath): 
    5353  """ 
    54   Creat a path for a directory and all needed parent forlders 
    55   -> parent directoryies will be created 
     54  Create a path for a directory and all needed parent forlders 
     55  -> parent directories will be created 
    5656  -> if directory already exists, then do nothing 
    57   -> if there is another filsystem object (like a file) with the same name, raise an exception 
     57  -> if there is another filesystem object (like a file) with the same name, raise an exception 
    5858  """ 
    5959  if not newPath: 
     
    8989    self.addCustomTime("imports done", importsDoneTimestamp) 
    9090 
    91     # constants & variable initilization 
     91    # constants & variable initialization 
    9292    self.dmod = None # device specific module 
    9393    self.gui = None 
    9494 
    95     self.d = {} # persistant dictionary of data 
     95    self.d = {} # persistent dictionary of data 
    9696    self.m = {} # dictionary of loaded modules 
    9797    self.watches = {} # List of data change watches 
     
    124124    self.configs = configs.Configs(self) 
    125125 
    126     # load persistant options 
     126    # load persistent options 
    127127    self.optLoadingOK= self._loadOptions() 
    128128 
     
    158158    """Load all modules from the specified directory""" 
    159159 
    160     # get the devicme module string 
     160    # get the device module string 
    161161    # (a unique device module string identificator) 
    162162    # make sure there is some argument provided 
     
    245245 
    246246    # add last timing checkpoint 
    247     self.addTime("all modules initilaized") 
     247    self.addTime("all modules initialized") 
    248248 
    249249  def _getModuleNamesFromFolder(self,folder): 
     
    275275    """to only update values needed for map drawing when something changes 
    276276       * window is resized 
    277        * user switches something releated in options 
     277       * user switches something related in options 
    278278       * etc. 
    279279       we use the key watching mechanism 
     
    350350    self._saveOptions() 
    351351    time.sleep(2) # leave some times for threads to shut down 
    352     print("Shuttdown complete") 
     352    print("Shutdown complete") 
    353353     
    354354  ## OPTIONS SETTING AND WATCHING ## 
     
    365365        # get the dictionary with per mode values 
    366366        multiDict = self.d.get('%s#multi' % name , {}) 
    367         # retrun the value for current mode 
     367        # return the value for current mode 
    368368        return multiDict.get(mode,default) 
    369369      else: 
     
    391391        except KeyError: # key not yet created 
    392392          self.d['%s#multi' % name] = {mode : value} 
    393       else: # just save to the key as usuall 
     393      else: # just save to the key as usual 
    394394        self.d[name] = value 
    395     else: # just save to the key as usuall 
     395    else: # just save to the key as usual 
    396396      self.d[name] = value 
    397397 
     
    399399    """options are normally saved on shutdown, 
    400400    but for some data we want to make sure they are stored and not 
    401     los for example becuase of power outage/empty battery, etc.""" 
     401    los for example because of power outage/empty battery, etc.""" 
    402402    if save: 
    403403      options = self.m.get('options') 
     
    410410 
    411411  def purgeKey(self, key): 
    412     """remove a key from the presistant dictionary, 
     412    """remove a key from the persistent dictionary, 
    413413    including possible key modifiers and alternate values""" 
    414414    if key in self.d: 
     
    426426      return True 
    427427    else: 
    428       print("modrana: can't purge a not present key: %s" % key) 
     428      print("modrana: can't purge a not-present key: %s" % key) 
    429429 
    430430  def watch(self, key, callback, *args): 
     
    456456    """run callbacks registered on an options key 
    457457    HOW IT WORKS 
    458     * the watcher is notified before the key is written to the persistant 
     458    * the watcher is notified before the key is written to the persistent 
    459459    dictionary, so that it can react before the change is visible 
    460460    * the watcher gets the key and both the new and old values 
     
    478478    dependent on the current mode""" 
    479479    options = self.m.get('options', None) 
    480     # remeber the old value, if not se use default from options 
     480    # remember the old value, if not se use default from options 
    481481    # if available 
    482482    if options: 
     
    523523        # get the previous value 
    524524        options = self.m.get('options', None) 
    525         # remeber the old value, if not se use default from options 
     525        # remember the old value, if not se use default from options 
    526526        # if available 
    527527        if options: 
     
    605605      elif shiftDirection == "right": 
    606606        x =  + sw * 0.5 * floatShiftAmount 
    607       """ we dont need to do anything if direction is set to don't shift (False) 
     607      """ we don't need to do anything if direction is set to don't shift (False) 
    608608      - 0,0 will be used """ 
    609609    self.centerShift = (x,y) 
     
    617617    (centerX,centerY) = ((sw/2.0),(sh/2.0)) 
    618618    ulCenterDistance = simplePythagoreanDistance(0, 0, centerX, centerY) 
    619     centerLLdistance = simplePythagoreanDistance(centerX, centerY, sw, sh) 
    620     diagonal = max(ulCenterDistance, centerLLdistance) 
     619    centerLLDistance = simplePythagoreanDistance(centerX, centerY, sw, sh) 
     620    diagonal = max(ulCenterDistance, centerLLDistance) 
    621621    add = int(math.ceil(float(diagonal)/tileSide)) 
    622622    self.expandViewportTiles = add 
     
    635635      # try to get some value if the old value is not available 
    636636      options = self.m.get('options', None) 
    637       # remeber the old value, if not se use default from options 
     637      # remember the old value, if not se use default from options 
    638638      # if available 
    639639      if options: 
     
    674674  def _loadOptions(self): 
    675675    print("modRana: loading options") 
    676     succcess = False 
     676    success = False 
    677677    try: 
    678678      f = open(self.paths.getOptionsFilePath(), "r") 
     
    686686      for k,v in newData.items(): 
    687687        self.set(k,v) 
    688       succcess = True 
     688      success = True 
    689689    except Exception, e: 
    690690      print("modRana: exception while loading saved options:\n%s" % e) 
    691691      #TODO: a yes/no dialog for clearing (renaming with timestamp :) the corrupted options file (options.bin) 
    692       succcess = False 
     692      success = False 
    693693 
    694694    self.overrideOptions() 
    695     return succcess 
     695    return success 
    696696 
    697697  def overrideOptions(self): 
Note: See TracChangeset for help on using the changeset viewer.