brightway-basic-explorer 0.9.dev5__tar.gz → 0.9.dev7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/PKG-INFO +26 -4
  2. brightway_basic_explorer-0.9.dev7/README.md +50 -0
  3. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer/__init__.py +30 -22
  4. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer.egg-info/PKG-INFO +26 -4
  5. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/pyproject.toml +1 -1
  6. brightway_basic_explorer-0.9.dev5/README.md +0 -28
  7. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/COPYING +0 -0
  8. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer/icons/emission.png +0 -0
  9. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer/icons/natural_resource.png +0 -0
  10. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer/icons/process.png +0 -0
  11. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer/icons/unknown.png +0 -0
  12. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer.egg-info/SOURCES.txt +0 -0
  13. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer.egg-info/dependency_links.txt +0 -0
  14. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer.egg-info/requires.txt +0 -0
  15. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/brightway_basic_explorer.egg-info/top_level.txt +0 -0
  16. {brightway_basic_explorer-0.9.dev5 → brightway_basic_explorer-0.9.dev7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brightway-basic-explorer
3
- Version: 0.9.dev5
3
+ Version: 0.9.dev7
4
4
  Summary: Implement basic GUI to explorer brightway ativities
5
5
  Author-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>, OIE - Mines Paris PSL <benoit.gschwind@minesparis.psl.eu>
6
6
  Maintainer-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>
@@ -29,13 +29,15 @@ Implement a basic activity explorer mostly to use in interractive python such as
29
29
  pip install brightway_basic_explorer
30
30
  ```
31
31
 
32
- # Sample and Documentation
32
+ # Documentation
33
33
 
34
34
  ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
35
35
 
36
+ ## Show an activity
37
+
36
38
  ```python
37
39
  import bw2data
38
- from brightway_basic_explorer import show_activity, close_all
40
+ from brightway_basic_explorer import show_activity, close_all, search
39
41
 
40
42
  db = bw2data.Database("ecoinvent-3.11-cutoff")
41
43
 
@@ -43,7 +45,27 @@ act = db.search("570kWp")
43
45
 
44
46
  # Show the first activity
45
47
  show_activity(act[0])
48
+ ```
46
49
 
47
- # Close all activity windows
50
+ ## Close all activities windows
51
+
52
+ ```python
48
53
  close_all()
49
54
  ```
55
+
56
+ ## With lca_algebraic
57
+
58
+ If you are ussing lca_algebraic, you can specify parameters. Parameters are completed by default values and used in formula to compute the corresponding amount.
59
+
60
+ ```python
61
+ show_activity(act[0], {"paramter0": 10, "parameter1": 20})
62
+ ```
63
+
64
+ ## Search within a database:
65
+
66
+ You can search within a database. Search require at less a not too short keyword. Keyword are separated by spaces, for instance:
67
+
68
+ ```python
69
+ search("ecoinvent-3.11-cutoff", "570kwp GLO")
70
+ ```
71
+
@@ -0,0 +1,50 @@
1
+ # Brightway Basic Explorer
2
+
3
+ Implement a basic activity explorer mostly to use in interractive python such as notebooks, ipython and spyder.
4
+
5
+ # Install
6
+
7
+ ```
8
+ pip install brightway_basic_explorer
9
+ ```
10
+
11
+ # Documentation
12
+
13
+ ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
14
+
15
+ ## Show an activity
16
+
17
+ ```python
18
+ import bw2data
19
+ from brightway_basic_explorer import show_activity, close_all, search
20
+
21
+ db = bw2data.Database("ecoinvent-3.11-cutoff")
22
+
23
+ act = db.search("570kWp")
24
+
25
+ # Show the first activity
26
+ show_activity(act[0])
27
+ ```
28
+
29
+ ## Close all activities windows
30
+
31
+ ```python
32
+ close_all()
33
+ ```
34
+
35
+ ## With lca_algebraic
36
+
37
+ If you are ussing lca_algebraic, you can specify parameters. Parameters are completed by default values and used in formula to compute the corresponding amount.
38
+
39
+ ```python
40
+ show_activity(act[0], {"paramter0": 10, "parameter1": 20})
41
+ ```
42
+
43
+ ## Search within a database:
44
+
45
+ You can search within a database. Search require at less a not too short keyword. Keyword are separated by spaces, for instance:
46
+
47
+ ```python
48
+ search("ecoinvent-3.11-cutoff", "570kwp GLO")
49
+ ```
50
+
@@ -52,19 +52,19 @@ def activity_to_json_with_params(act, params):
52
52
  a["exchanges"] = exs
53
53
  return a
54
54
 
55
- class MessageDialog(QtGui.QDialog):
56
- def __init__(self, msg):
57
- super().__init__()
58
- self.msg = msg
59
-
60
- layout = QtGui.QVBoxLayout()
61
- self.setLayout(layout)
62
- layout.addWidget(QtGui.QLabel(msg))
63
-
64
- self.button = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.StandardButton.Ok)
65
- layout.addWidget(self.button)
66
- self.button.accepted.connect(self.close)
67
-
55
+ def warn_dialog(msg):
56
+ print(f"WARNING: {msg}")
57
+ w = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning, "WARNING", msg)
58
+ w.show()
59
+ w.setMaximumSize(800, 600)
60
+ w.exec()
61
+
62
+ def fatal_dialog(msg):
63
+ print(f"ERROR: {msg}")
64
+ w = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Critical, "ERROR", msg)
65
+ w.show()
66
+ w.setMaximumSize(800, 600)
67
+ w.exec()
68
68
 
69
69
  class QStandardItemRO(QtGui.QStandardItem):
70
70
  def __init__(self, *args, data=None, **kwargs):
@@ -117,8 +117,11 @@ class ActionMenu(QtGui.QMenu):
117
117
  self.action_copy = self.addAction("Copy")
118
118
  self.action_copy.triggered.connect(self.copy_triggered)
119
119
 
120
- self.action_copy = self.addAction("Copy Full Reference")
121
- self.action_copy.triggered.connect(self.copy_full_reference_triggered)
120
+ self.action_copy_ref = self.addAction("Copy Full Reference")
121
+ self.action_copy_ref.triggered.connect(self.copy_full_reference_triggered)
122
+
123
+ self.action_copy_code = self.addAction("Copy Activity Code")
124
+ self.action_copy_code.triggered.connect(self.copy_code_triggered)
122
125
 
123
126
  if hasattr(self.parentWidget(), "explore"):
124
127
  self.action_explore = self.addAction("Explore")
@@ -137,6 +140,12 @@ class ActionMenu(QtGui.QMenu):
137
140
  text = (v["database"], v["name"], v.get("location", None), v.get("categories", tuple()), v.get("unit", None))
138
141
  QtGui.QGuiApplication.clipboard().setText(str(text))
139
142
 
143
+ def copy_code_triggered(self):
144
+ parent = self.parentWidget()
145
+ v = parent.model.root.child(self.index.row(), 0).data()
146
+ text = (v["database"], v["code"])
147
+ QtGui.QGuiApplication.clipboard().setText(str(text))
148
+
140
149
  def explore_triggered(self):
141
150
  self.parentWidget().explore(self.index)
142
151
 
@@ -213,7 +222,7 @@ class ActivityTab(QtGui.QWidget):
213
222
  grid = QtGui.QGridLayout()
214
223
  layout.addLayout(grid)
215
224
 
216
- for i, k in enumerate(["database", "name", "location", "unit", "categories", "type"]):
225
+ for i, k in enumerate(["database", "name", "location", "unit", "categories", "type", "reference product"]):
217
226
  grid.addWidget(QtGui.QLabel(f"{k}:"), i, 0)
218
227
  x = QtGui.QLabel(f"{str(activity_json.get(k, '-'))}")
219
228
  x.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
@@ -386,9 +395,7 @@ class SearchWindow(QtGui.QMainWindow):
386
395
  text = self.keywords.text()
387
396
  keywords = [re.sub("[^a-zA-Z0-9_-]", "", s) for s in text.split(" ") if len(s) > 0]
388
397
  if all(len(x) < 3 for x in keywords):
389
- w = MessageDialog("Too smalls keywords")
390
- w.setWindowTitle("WARNING")
391
- w.exec()
398
+ warn_dialog("Too smalls keywords")
392
399
  return
393
400
 
394
401
  acts = self.db.search(" ".join(keywords), proxy=True, limit=200)
@@ -463,6 +470,9 @@ def show_activity(act, params=None):
463
470
 
464
471
  app = get_app_qt4()
465
472
 
473
+ if isinstance(act, tuple):
474
+ act = bw2data.get_activity(act)
475
+
466
476
  if params is None:
467
477
  activity_json = activity_to_json(act)
468
478
  else:
@@ -489,9 +499,7 @@ def search(database, keywords=""):
489
499
 
490
500
  if isinstance(database, str):
491
501
  if database not in bw2data.databases:
492
- w = MessageDialog(f"Database {database} not found !")
493
- w.setWindowTitle("WARNING")
494
- w.exec()
502
+ fatal_dialog(f"Database {database} not found !")
495
503
  return
496
504
  database = bw2data.Database(database)
497
505
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brightway-basic-explorer
3
- Version: 0.9.dev5
3
+ Version: 0.9.dev7
4
4
  Summary: Implement basic GUI to explorer brightway ativities
5
5
  Author-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>, OIE - Mines Paris PSL <benoit.gschwind@minesparis.psl.eu>
6
6
  Maintainer-email: Benoît GSCHWIND <benoit.gschwind@minesparis.psl.eu>
@@ -29,13 +29,15 @@ Implement a basic activity explorer mostly to use in interractive python such as
29
29
  pip install brightway_basic_explorer
30
30
  ```
31
31
 
32
- # Sample and Documentation
32
+ # Documentation
33
33
 
34
34
  ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
35
35
 
36
+ ## Show an activity
37
+
36
38
  ```python
37
39
  import bw2data
38
- from brightway_basic_explorer import show_activity, close_all
40
+ from brightway_basic_explorer import show_activity, close_all, search
39
41
 
40
42
  db = bw2data.Database("ecoinvent-3.11-cutoff")
41
43
 
@@ -43,7 +45,27 @@ act = db.search("570kWp")
43
45
 
44
46
  # Show the first activity
45
47
  show_activity(act[0])
48
+ ```
46
49
 
47
- # Close all activity windows
50
+ ## Close all activities windows
51
+
52
+ ```python
48
53
  close_all()
49
54
  ```
55
+
56
+ ## With lca_algebraic
57
+
58
+ If you are ussing lca_algebraic, you can specify parameters. Parameters are completed by default values and used in formula to compute the corresponding amount.
59
+
60
+ ```python
61
+ show_activity(act[0], {"paramter0": 10, "parameter1": 20})
62
+ ```
63
+
64
+ ## Search within a database:
65
+
66
+ You can search within a database. Search require at less a not too short keyword. Keyword are separated by spaces, for instance:
67
+
68
+ ```python
69
+ search("ecoinvent-3.11-cutoff", "570kwp GLO")
70
+ ```
71
+
@@ -12,7 +12,7 @@ name = "brightway-basic-explorer"
12
12
  description = "Implement basic GUI to explorer brightway ativities"
13
13
  readme = "README.md"
14
14
  license-files = ["COPYING"]
15
- version = "0.9.dev5"
15
+ version = "0.9.dev7"
16
16
  dependencies = [ "ipython" ]
17
17
  requires-python = ">= 3.10"
18
18
  keywords = ["lca", "ecoinvent", "brightway"]
@@ -1,28 +0,0 @@
1
- # Brightway Basic Explorer
2
-
3
- Implement a basic activity explorer mostly to use in interractive python such as notebooks, ipython and spyder.
4
-
5
- # Install
6
-
7
- ```
8
- pip install brightway_basic_explorer
9
- ```
10
-
11
- # Sample and Documentation
12
-
13
- ![Sample Window](https://github.com/gschwind/brightway-basic-explorer/raw/main/doc/sample-window.png)
14
-
15
- ```python
16
- import bw2data
17
- from brightway_basic_explorer import show_activity, close_all
18
-
19
- db = bw2data.Database("ecoinvent-3.11-cutoff")
20
-
21
- act = db.search("570kWp")
22
-
23
- # Show the first activity
24
- show_activity(act[0])
25
-
26
- # Close all activity windows
27
- close_all()
28
- ```