Commits

Chris Mutel committed 45f594f

Make updates functional

  • Participants
  • Parent commits 3a6d804

Comments (0)

Files changed (2)

File bw2data/bin/bw2-uptodate.py

 
 Usage:
   bw2-uptodate.py
-  bw2-uptodate.py --list
+  bw2-uptodate.py -l | --list
   bw2-uptodate.py -h | --help
   bw2-uptodate.py --version
 
         config.create_basic_directories()
         args = docopt(__doc__, version='Brightway2 up to date 0.1')
         updater_interface = UpdaterInterface()
-        if args['--list']:
+        if args['--list'] or args['-l']:
             updater_interface.list()
         else:
             updater_interface.update()

File bw2data/updates.py

     def explain(key):
         return Updates.UPDATES[key]['explanation']
 
+    @staticmethod
     def do_update(key):
-        method = getattr(Update, Updates.UPDATES[key]['method'])
+        method = getattr(Updates, Updates.UPDATES[key]['method'])
         method()
         config.p['updates'][key] = True
         config.save_preferences()
             config.p['updates'] = {key: True for key in Updates.UPDATES}
             config.save_preferences()
         else:
-            updates = sorted([key for key in Updates.UPDATES if not Updates.UPDATES.get(key)])
+            updates = sorted([key for key in Updates.UPDATES if not config.p['updates'].get(key)])
         if updates and verbose:
             with safe_colorama():
                 warnings.warn(UPTODATE_WARNING)
 
     @staticmethod
     def reprocess_all_methods():
-        for method_key in methods:
+        print "Updating all LCIA methods"
+
+        widgets = [
+            'Methods: ',
+            progressbar.Percentage(),
+            ' ',
+            progressbar.Bar(marker=progressbar.RotatingMarker()),
+            ' ',
+            progressbar.ETA()
+        ]
+        pbar = progressbar.ProgressBar(
+            widgets=widgets,
+            maxval=len(methods)
+        ).start()
+
+        for index, method_key in enumerate(methods):
             method = Method(method_key)
             method_data = method.load()
+            methods[method_key]['abbreviation_old'] = \
+                methods[method_key]['abbreviation']
             methods[method_key]['abbreviation'] = abbreviate(method_key)
+            methods.flush()
             method.write(method_data)
             method.process()
+            pbar.update(index)
 
+        pbar.finish()
 
     @staticmethod
     def units_renormalize():
             ]
             pbar = progressbar.ProgressBar(
                 widgets=widgets,
-                maxval=len(databases.list)
+                maxval=len(databases)
             ).start()
 
             for index, database in enumerate(databases.list):
             ]
             pbar = progressbar.ProgressBar(
                 widgets=widgets,
-                maxval=len(methods.list)
+                maxval=len(methods)
             ).start()
 
             for index, method in enumerate(methods.list):