File tree Expand file tree Collapse file tree
activity_browser/ui/wizards Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22import brightway2 as bw
33from PySide2 import QtWidgets , QtCore
4+ from peewee import SqliteDatabase
45import os
56import re
67
@@ -109,12 +110,12 @@ def __init__(self, parent=None):
109110
110111 def bw_projects (self , path : str ):
111112 """ Finds the bw_projects from the brightway2 environment provided by path"""
112- projects = []
113- for dir in [ dir for dir in os . listdir ( path ) if os .path .isdir (path + "/" + dir )]:
114- project = re . match ( r'(\w+)\.' , dir )
115- if project :
116- projects . append ( project . group ( 1 ) )
117- return projects
113+ # open the project database
114+ db = SqliteDatabase ( os .path .join (path , "projects.db" ))
115+
116+ # find all project names using sql query and return
117+ cursor = db . execute_sql ( 'SELECT "name" FROM "projectdataset"' )
118+ return [ i [ 0 ] for i in cursor . fetchall ()]
118119
119120 def restore_defaults (self ):
120121 self .change_bw_dir (ab_settings .get_default_directory ())
You can’t perform that action at this time.
0 commit comments