Skip to content

Commit

Permalink
Revert initial attempt to separate out the web importer stuff to a pl…
Browse files Browse the repository at this point in the history
…ugin. Field editor work: expanded the treeview and added a header that allows for sorting alphabetically. Also applied patch to db.py to comply with sqlalchemy 1.4
  • Loading branch information
winshipvarner committed Oct 3, 2024
1 parent ff6c266 commit c824dc7
Show file tree
Hide file tree
Showing 25 changed files with 109 additions and 65 deletions.
13 changes: 10 additions & 3 deletions .pybuild/cpython3_3.12/build/gourmand/backends/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,16 @@ def fetch_len (self, table, **criteria):
"""Return the number of rows in table that match criteria
"""
if criteria:
return select(func.count(criteria)).select_from(table).scalar()
else:
return select(func.count()).select_from(table).scalar()
return select(
[func.count(list(table.primary_key.columns)[0])])\
.where(*make_simple_select_arg(criteria,table))\
.execute()\
.fetchone()[0]

return select(
[func.count(list(table.primary_key.columns)[0])])\
.execute()\
.fetchone()[0]

def fetch_join (self, table1, table2, col1, col2,
column_names=None, sort_by=None, **criteria):
Expand Down
10 changes: 5 additions & 5 deletions .pybuild/cpython3_3.12/build/gourmand/defaults/defaults_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,12 @@ class Language(AbstractLanguage):
("qt", ["quart", "quarts", "qt.", "Qt", "Qt."]),
("pt", ["pint", "pints", "pt.", "Pt", "Pt."]),
("gallon", ["gallon", "gallons", "gal", "gal."]),
("ml", ["mililiter", "mililiters", "ml", "ml."]),
("cl", ["centiliter", "centiliters","cl", "cl."]),
("dl", ["deciliter", "deciliters", "dl", "dl."]),
("l", ["liter", "liters", "lit.", "l", "l."]),
("ml", ["mililiter", "mililiters", "milliliter", "milliliters", "millilitre", "millilitres", "ml", "ml."]),
("cl", ["centiliter", "centiliters","centilitre", "centilitres", "cl", "cl."]),
("dl", ["deciliter", "deciliters", "decilitre", "deciilitres", "dl", "dl."]),
("l", ["liter", "liters", "litre", "litres""lit.", "l", "l."]),
("g", ["grams", "gram", "g.", "g", "gr", "gr."]),
("mg", ["miligram", "miligrams", "mg", "mg."]),
("mg", ["miligram", "miligrams", "millogram", "millograms", "mg", "mg."]),
("kg", ["kilogram", "kilograms", "kg", "kg."]),
# These names aren"t really convertible, but we want them to
# be recognized as units.
Expand Down
10 changes: 5 additions & 5 deletions .pybuild/cpython3_3.12/build/gourmand/defaults/defaults_en_GB.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ class Language(AbstractLanguage):
("qt", ["quart", "quarts", "qt.", "Qt", "Qt."]),
("pt", ["pint", "pints", "pt.", "Pt", "Pt."]),
("gallon", ["gallon", "gallons", "gal", "gal."]),
("ml", ["mililiter", "mililiters", "ml", "ml."]),
("cl", ["centiliter", "centiliters","cl", "cl."]),
("dl", ["deciliter", "deciliters", "dl", "dl."]),
("l", ["liter", "liters", "lit.", "l", "l."]),
("ml", ["mililiter", "mililiters", "milliliter", "milliliters", "millilitre", "millilitres", "ml", "ml."]),
("cl", ["centiliter", "centiliters","centilitre", "centilitres", "cl", "cl."]),
("dl", ["deciliter", "deciliters", "decilitre", "deciilitres", "dl", "dl."]),
("l", ["liter", "liters", "litre", "litres""lit.", "l", "l."]),
("g", ["grams", "gram", "g.", "g", "gr", "gr."]),
("mg", ["miligram", "miligrams", "mg", "mg."]),
("mg", ["miligram", "miligrams", "millogram", "millograms", "mg", "mg."]),
("kg", ["kilogram", "kilograms", "kg", "kg."]),
# These names aren"t really convertible, but we want them to
# be recognized as units.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gourmand.gtk_extras.dialog_extras as de
import gourmand.plugin_loader as plugin_loader
from gourmand.i18n import _
#from gourmand.importers.web_importer import import_urls, supported_sites
from gourmand.importers.web_importer import import_urls, supported_sites
from gourmand.importers.interactive_importer import import_interactivally
from gourmand.plugin import ImporterPlugin, ImportManagerPlugin
from gourmand.threadManager import (NotThreadSafe, get_thread_manager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def __init__ (self, rd, rg):
})

def __setup_widgets__ (self):
sorted_model = Gtk.TreeModelSort()
#sorted_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
for w in [
'valueDialog',
'treeview',
'treeview', 'model=sorted_model',
'fieldToEditCombo','newValueComboBoxEntry',
'newValueEntry','changeValueButton',
'deleteValueButton','forEachLabel',
Expand Down Expand Up @@ -83,6 +85,7 @@ def __setup_treeview__ (self):
col = Gtk.TreeViewColumn('Value',
renderer,
text=0)
col.set_sort_column_id(0)
self.treeview.append_column(col)
self.treeview.get_selection().connect('changed',self.treeViewSelectionChanged)
self.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
Expand Down
3 changes: 2 additions & 1 deletion .pybuild/cpython3_3.12/build/gourmand/ui/valueEditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="headers_visible">False</property>
<property name="headers_visible">True</property>
</object>
</child>
</object>
Expand Down
2 changes: 1 addition & 1 deletion debian/gourmand.substvars
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python3:Depends=python3-bs4 (>= 4.10.0), python3-gi, python3-lxml, python3-pil, python3-sqlalchemy (<< 2), python3-toml, python3:any
python3:Depends=python3-bs4 (>= 4.10.0), python3-gi, python3-lxml, python3-pil, python3-recipe-scrapers, python3-sqlalchemy (<< 2), python3-toml, python3:any
misc:Depends=
misc:Pre-Depends=
6 changes: 3 additions & 3 deletions debian/gourmand/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Package: gourmand
Version: 1.1.1
Architecture: all
Maintainer: Winship Varner <[email protected]>
Installed-Size: 10776
Depends: python3-bs4 (>= 4.10.0), python3-gi, python3-lxml, python3-pil, python3-sqlalchemy (<< 2), python3-toml, python3:any, python3-gi-cairo, gir1.2-gtk-3.0, python3-reportlab, python3-keyring, python3-argcomplete, python3-gst-1.0
Recommends: python3-pyglet, python3-gtkspellcheck, gir1.2-poppler-0.18, python3-ebooklib, python3-recipe-scrapers
Installed-Size: 10777
Depends: python3-bs4 (>= 4.10.0), python3-gi, python3-lxml, python3-pil, python3-recipe-scrapers, python3-sqlalchemy (<< 2), python3-toml, python3:any, python3-gi-cairo, gir1.2-gtk-3.0, python3-reportlab, python3-keyring, python3-argcomplete, python3-gst-1.0
Recommends: python3-pyglet, python3-gtkspellcheck, gir1.2-poppler-0.18, python3-ebooklib
Section: gnome
Priority: optional
Homepage: https://github.com/GourmandRecipeManager/gourmand
Expand Down
16 changes: 8 additions & 8 deletions debian/gourmand/DEBIAN/md5sums
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
501140cfece552486a582c2e4f5d65ed usr/bin/gourmand
acca15615ce244603af116213bb87f55 usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/PKG-INFO
f536261df8e65275b24d4720f3ead738 usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/PKG-INFO
68b329da9893e34099c7d8ad5cb9c940 usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/dependency_links.txt
39f1581e74480f0f6247689c19bf2bcb usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/entry_points.txt
b7dea96900db6ce57645d31a178750fe usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/requires.txt
7b61e6a45e9eb22b5e8ffd5c5cf58c49 usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/requires.txt
60ff9dc9b5e4f74bf73bcc0dbb47ab4a usr/lib/python3/dist-packages/gourmand-1.1.1.egg-info/top_level.txt
8a266edc82f834bc4517a546daef332d usr/lib/python3/dist-packages/gourmand/Undo.py
8c496a9c181adddab1d18d32ebc4362a usr/lib/python3/dist-packages/gourmand/__init__.py
6a26d3347834de6e3f95dd00ec76e6f2 usr/lib/python3/dist-packages/gourmand/__main__.py
2f90ce288dd50b67821c84965f1f83be usr/lib/python3/dist-packages/gourmand/__version__.py
3d69d104145ea69b9d64420f9f099f56 usr/lib/python3/dist-packages/gourmand/backends/DatabaseChooser.py
2b81e648d0b42924563fa3ba2eaf5a9a usr/lib/python3/dist-packages/gourmand/backends/__init__.py
9504cf154317cc8847f0f5cb9095ebfe usr/lib/python3/dist-packages/gourmand/backends/db.py
10a9e52ddc1732341bf14dee2bc57882 usr/lib/python3/dist-packages/gourmand/backends/db.py
df34fcbb498437f4a31d70ae8ed674c8 usr/lib/python3/dist-packages/gourmand/backends/default.db
03379fd3eba827fc18afdb77e662cca6 usr/lib/python3/dist-packages/gourmand/batchEditor.py
055251f98e2ee914a90ddb74653f328d usr/lib/python3/dist-packages/gourmand/check_encodings.py
Expand Down Expand Up @@ -100,8 +100,8 @@ b50618072bf7b9463477eb4a33ef8707 usr/lib/python3/dist-packages/gourmand/data/so
416e924f10d07b83ce39b2eac4572477 usr/lib/python3/dist-packages/gourmand/defaults/abstractLang.py
6d2e40f7a0239070417a64c509700175 usr/lib/python3/dist-packages/gourmand/defaults/defaults.py
e188c44054d2083244b3ca30073a5d67 usr/lib/python3/dist-packages/gourmand/defaults/defaults_de.py
17741e7e746b81247a8e485d11105ce9 usr/lib/python3/dist-packages/gourmand/defaults/defaults_en.py
0dc7ab3426ee4f79fc0ec1ffc570730c usr/lib/python3/dist-packages/gourmand/defaults/defaults_en_GB.py
d9663e1034436a09ba2bfc9ddf8ed8d0 usr/lib/python3/dist-packages/gourmand/defaults/defaults_en.py
292c08de408f512f38c9b4aceaef56e7 usr/lib/python3/dist-packages/gourmand/defaults/defaults_en_GB.py
aebf1a3b2c65f2146718c864e90c5e5d usr/lib/python3/dist-packages/gourmand/defaults/defaults_es.py
c7608f1a719400af87617db418d20b4d usr/lib/python3/dist-packages/gourmand/defaults/defaults_fr.py
abcfb069fff444a7a16899a6cf0a5a41 usr/lib/python3/dist-packages/gourmand/defaults/defaults_nl.py
Expand Down Expand Up @@ -140,7 +140,7 @@ f144ae92680903a8a7a07d7bcd338cd1 usr/lib/python3/dist-packages/gourmand/gtk_ext
d41d8cd98f00b204e9800998ecf8427e usr/lib/python3/dist-packages/gourmand/importers/__init__.py
ae16c81929484c0d46836cd6fd314a9e usr/lib/python3/dist-packages/gourmand/importers/clipboard_importer.py
b326807152e549857bf2c77651f2e0c9 usr/lib/python3/dist-packages/gourmand/importers/generic_recipe_parser.py
829297b889cd800e56e93785d40e3a36 usr/lib/python3/dist-packages/gourmand/importers/importManager.py
688046ad935fe3130cc73b50d1db6471 usr/lib/python3/dist-packages/gourmand/importers/importManager.py
cb7b3441a94c4780c36a9cdc2599cf00 usr/lib/python3/dist-packages/gourmand/importers/importer.py
bb01b0a79ffbfa95164eccb96af96b20 usr/lib/python3/dist-packages/gourmand/importers/interactive_importer.py
3c87fd23bcf155d5bae91150b690039e usr/lib/python3/dist-packages/gourmand/importers/plaintext_importer.py
Expand Down Expand Up @@ -180,7 +180,7 @@ e3317dc852cb0e5d1fdb3daed60e0097 usr/lib/python3/dist-packages/gourmand/plugins
a7795f53ef1801c6feec7690d47857a6 usr/lib/python3/dist-packages/gourmand/plugins/email_plugin/recipe_emailer.py
d6df165ec6b821f711f9076e3b80f0fd usr/lib/python3/dist-packages/gourmand/plugins/field_editor.gourmet-plugin
dbfa20d4f127c706eabfbc0f57aa4e8d usr/lib/python3/dist-packages/gourmand/plugins/field_editor/__init__.py
de10a71b669dd7109fc7668f60addb64 usr/lib/python3/dist-packages/gourmand/plugins/field_editor/fieldEditor.py
da2402b418a5683d6edf43ba69b3a962 usr/lib/python3/dist-packages/gourmand/plugins/field_editor/fieldEditor.py
c6b3243d4601367d557e3756cee22f6b usr/lib/python3/dist-packages/gourmand/plugins/import_export/epub.gourmet-plugin
6179ded23bd29314ba5f49436d40b4b5 usr/lib/python3/dist-packages/gourmand/plugins/import_export/epub_plugin/__init__.py
ef52e97e7b135d1330e278176d7910db usr/lib/python3/dist-packages/gourmand/plugins/import_export/epub_plugin/epub_exporter.py
Expand Down Expand Up @@ -300,7 +300,7 @@ b039dc676724ea54fc007246b6354206 usr/lib/python3/dist-packages/gourmand/ui/nutr
971b6d0391407465e1785c681d612f33 usr/lib/python3/dist-packages/gourmand/ui/recipe_index.ui
800ea7bb11b0ca4652acf8fdbd583bbb usr/lib/python3/dist-packages/gourmand/ui/shopCatEditor.ui
20265f7aede97b2f08daa848d3c83b0a usr/lib/python3/dist-packages/gourmand/ui/timerDialog.ui
b09698b9bcdf8a5b34fcb0c557dd4d4d usr/lib/python3/dist-packages/gourmand/ui/valueEditor.ui
fc94384de90b71f5c32c7e7b32659f22 usr/lib/python3/dist-packages/gourmand/ui/valueEditor.ui
a7d8914d850c1ec41276e4d103c465b5 usr/share/applications/io.github.GourmandRecipeManager.Gourmand.desktop
5d6c3dfe7cc937bb38081d96d2007756 usr/share/doc-base/gourmand.gourmand
3234117f1c29d2137981f1391c2816df usr/share/doc/gourmand/README.Debian
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,16 @@ def fetch_len (self, table, **criteria):
"""Return the number of rows in table that match criteria
"""
if criteria:
return select(func.count(criteria)).select_from(table).scalar()
else:
return select(func.count()).select_from(table).scalar()
return select(
[func.count(list(table.primary_key.columns)[0])])\
.where(*make_simple_select_arg(criteria,table))\
.execute()\
.fetchone()[0]

return select(
[func.count(list(table.primary_key.columns)[0])])\
.execute()\
.fetchone()[0]

def fetch_join (self, table1, table2, col1, col2,
column_names=None, sort_by=None, **criteria):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,12 @@ class Language(AbstractLanguage):
("qt", ["quart", "quarts", "qt.", "Qt", "Qt."]),
("pt", ["pint", "pints", "pt.", "Pt", "Pt."]),
("gallon", ["gallon", "gallons", "gal", "gal."]),
("ml", ["mililiter", "mililiters", "ml", "ml."]),
("cl", ["centiliter", "centiliters","cl", "cl."]),
("dl", ["deciliter", "deciliters", "dl", "dl."]),
("l", ["liter", "liters", "lit.", "l", "l."]),
("ml", ["mililiter", "mililiters", "milliliter", "milliliters", "millilitre", "millilitres", "ml", "ml."]),
("cl", ["centiliter", "centiliters","centilitre", "centilitres", "cl", "cl."]),
("dl", ["deciliter", "deciliters", "decilitre", "deciilitres", "dl", "dl."]),
("l", ["liter", "liters", "litre", "litres""lit.", "l", "l."]),
("g", ["grams", "gram", "g.", "g", "gr", "gr."]),
("mg", ["miligram", "miligrams", "mg", "mg."]),
("mg", ["miligram", "miligrams", "millogram", "millograms", "mg", "mg."]),
("kg", ["kilogram", "kilograms", "kg", "kg."]),
# These names aren"t really convertible, but we want them to
# be recognized as units.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ class Language(AbstractLanguage):
("qt", ["quart", "quarts", "qt.", "Qt", "Qt."]),
("pt", ["pint", "pints", "pt.", "Pt", "Pt."]),
("gallon", ["gallon", "gallons", "gal", "gal."]),
("ml", ["mililiter", "mililiters", "ml", "ml."]),
("cl", ["centiliter", "centiliters","cl", "cl."]),
("dl", ["deciliter", "deciliters", "dl", "dl."]),
("l", ["liter", "liters", "lit.", "l", "l."]),
("ml", ["mililiter", "mililiters", "milliliter", "milliliters", "millilitre", "millilitres", "ml", "ml."]),
("cl", ["centiliter", "centiliters","centilitre", "centilitres", "cl", "cl."]),
("dl", ["deciliter", "deciliters", "decilitre", "deciilitres", "dl", "dl."]),
("l", ["liter", "liters", "litre", "litres""lit.", "l", "l."]),
("g", ["grams", "gram", "g.", "g", "gr", "gr."]),
("mg", ["miligram", "miligrams", "mg", "mg."]),
("mg", ["miligram", "miligrams", "millogram", "millograms", "mg", "mg."]),
("kg", ["kilogram", "kilograms", "kg", "kg."]),
# These names aren"t really convertible, but we want them to
# be recognized as units.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gourmand.gtk_extras.dialog_extras as de
import gourmand.plugin_loader as plugin_loader
from gourmand.i18n import _
#from gourmand.importers.web_importer import import_urls, supported_sites
from gourmand.importers.web_importer import import_urls, supported_sites
from gourmand.importers.interactive_importer import import_interactivally
from gourmand.plugin import ImporterPlugin, ImportManagerPlugin
from gourmand.threadManager import (NotThreadSafe, get_thread_manager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def __init__ (self, rd, rg):
})

def __setup_widgets__ (self):
sorted_model = Gtk.TreeModelSort()
#sorted_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
for w in [
'valueDialog',
'treeview',
'treeview', 'model=sorted_model',
'fieldToEditCombo','newValueComboBoxEntry',
'newValueEntry','changeValueButton',
'deleteValueButton','forEachLabel',
Expand Down Expand Up @@ -83,6 +85,7 @@ def __setup_treeview__ (self):
col = Gtk.TreeViewColumn('Value',
renderer,
text=0)
col.set_sort_column_id(0)
self.treeview.append_column(col)
self.treeview.get_selection().connect('changed',self.treeViewSelectionChanged)
self.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="headers_visible">False</property>
<property name="headers_visible">True</property>
</object>
</child>
</object>
Expand Down
2 changes: 1 addition & 1 deletion development.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--editable .[epub-export,mycookbook,pdf-export,spellcheck,recipe_scrapers]
--editable .[epub-export,mycookbook,pdf-export,spellcheck]
dogtail
flake8
isort
Expand Down
13 changes: 12 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,15 @@ It is run with [pytest](https://docs.pytest.org/):
pytest
```

Most modern python IDEs have support for running the tests usin pytest.
Most modern python IDEs have support for running the tests using pytest.

## Debian Package

Here is how the Debian package is built:

```bash
pip3 install -e .
dh_make --indep --createorig --native --packagename gourmand_1.1.1
(deactivate; dpkg-buildpackage -us -uc -b)

```
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ def run(self):
'pygobject>=3.40.1',
'sqlalchemy<2',
'toml>=0.10.2',
#'recipe-scrapers>=14.27.0',
'recipe-scrapers>=14.27.0',
],
extras_require={
'epub-export': ['ebooklib>=0.17.1'],
'pdf-export': ['reportlab>=3.5.67'],
'spellcheck': ['pyenchant',
'pygtkspellcheck'],
'recipe_scrapers' : ['python3-recipe-scrapers']
#'recipe_scrapers' : ['python3-recipe-scrapers']
},
cmdclass={
'bdist_wheel': BuildWheel,
Expand Down
Loading

1 comment on commit c824dc7

@winshipvarner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added the correct spelling of "milli"(liters) and added the British spelling of litre. The patch to fix the compliance of db.py with sqlalchemy 1.14 is GourmandRecipeManager#85

Please sign in to comment.