oldnews 0.8.0__py3-none-any.whl → 0.9.0__py3-none-any.whl

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.
oldnews/data/db.py DELETED
@@ -1,97 +0,0 @@
1
- """Code for working with the backend database."""
2
-
3
- ##############################################################################
4
- # Python imports.
5
- from pathlib import Path
6
-
7
- ##############################################################################
8
- # TypeDAL imports.
9
- from typedal import TypeDAL
10
- from typedal.config import TypeDALConfig
11
-
12
- ##############################################################################
13
- # Local imports.
14
- from .last_grab import LastGrabbed
15
- from .local_articles import LocalArticle, LocalArticleAlternate, LocalArticleCategory
16
- from .local_folders import LocalFolder
17
- from .local_subscriptions import LocalSubscription, LocalSubscriptionCategory
18
- from .locations import data_dir
19
- from .navigation_state import NavigationState
20
- from .tools import safely_index
21
-
22
-
23
- ##############################################################################
24
- def db_file() -> Path:
25
- """Get the file that contains the database.
26
-
27
- Returns:
28
- The file that contains the database.
29
- """
30
- return data_dir() / "oldnews.db"
31
-
32
-
33
- ##############################################################################
34
- def initialise_database() -> TypeDAL:
35
- """Create the database.
36
-
37
- Returns:
38
- The database.
39
- """
40
- # Note the passing of an empty TypeDALConfig. Not doing this seems to
41
- # result in a:
42
- #
43
- # Could not load typedal config toml: 'typedal'
44
- #
45
- # warning to stdout, otherwise.
46
- dal = TypeDAL(f"sqlite://{db_file()}", folder=data_dir(), config=TypeDALConfig())
47
-
48
- dal.define(LocalArticle)
49
- safely_index(LocalArticle, "idx_local_article_article_id", LocalArticle.article_id)
50
- safely_index(
51
- LocalArticle,
52
- "idx_local_article_origin_stream_id",
53
- LocalArticle.origin_stream_id,
54
- )
55
-
56
- dal.define(LocalArticleCategory)
57
- safely_index(
58
- LocalArticleCategory,
59
- "idx_local_article_category_article",
60
- LocalArticleCategory.article,
61
- )
62
- safely_index(
63
- LocalArticleCategory,
64
- "idx_local_article_category_category",
65
- LocalArticleCategory.category,
66
- )
67
-
68
- dal.define(LocalArticleAlternate)
69
-
70
- dal.define(LocalFolder)
71
-
72
- dal.define(LocalSubscription)
73
- safely_index(
74
- LocalSubscription,
75
- "idx_local_subscription_subscription_id",
76
- LocalSubscription.subscription_id,
77
- )
78
-
79
- dal.define(LocalSubscriptionCategory)
80
- safely_index(
81
- LocalSubscriptionCategory,
82
- "idx_local_subscription_category_subscription",
83
- LocalSubscriptionCategory.subscription,
84
- )
85
- safely_index(
86
- LocalSubscriptionCategory,
87
- "idx_local_subscription_category_category_id",
88
- LocalSubscriptionCategory.category_id,
89
- )
90
-
91
- dal.define(NavigationState)
92
- dal.define(LastGrabbed)
93
-
94
- return dal
95
-
96
-
97
- ### db.py ends here
oldnews/data/tools.py DELETED
@@ -1,45 +0,0 @@
1
- """Database tool functions."""
2
-
3
- ##############################################################################
4
- # Python imports.
5
- from typing import Any
6
-
7
- ##############################################################################
8
- # TypeDAL imports.
9
- from typedal import TypedField, TypedTable
10
- from typedal.helpers import get_db, get_field
11
- from typedal.types import Field
12
-
13
-
14
- ##############################################################################
15
- def safely_index(
16
- table: type[TypedTable], name: str, field: str | Field | TypedField[Any]
17
- ) -> None:
18
- """Create an index on a type, but handle errors.
19
-
20
- Args:
21
- table: The table to create the index against.
22
- name: The name of the index.
23
- field: The field to index.
24
-
25
- Notes:
26
- From what I can gather TypeDAL *should* only create the index if it
27
- doesn't exist. Instead it throws an error if it exists. So here I
28
- swallow the `RuntimeError`. Hopefully there is a better way and I've
29
- just missed it.
30
- """
31
- try:
32
- table.create_index(
33
- name, get_field(field) if isinstance(field, TypedField) else field
34
- )
35
- except RuntimeError:
36
- pass
37
-
38
-
39
- ##############################################################################
40
- def commit(table: type[TypedTable]) -> None:
41
- """Commit changes."""
42
- get_db(table()).commit()
43
-
44
-
45
- ### tools.py ends here
@@ -1,40 +0,0 @@
1
- oldnews/__init__.py,sha256=p5a3l8kly6VYQ4IjiC6s03Nj-FaLDTOzqU1ZC6WZLl0,540
2
- oldnews/__main__.py,sha256=RJCfjo9MVOYC1K6G7YG7jH8NPMqRzW79SZTcbsoViG0,4703
3
- oldnews/commands/__init__.py,sha256=R8w9ccEYqZ4AKdtg2vvT_ejgdC3rsQ7yiTVnYVWDLOQ,1042
4
- oldnews/commands/main.py,sha256=lPfOIYwf8L7eYG9GUy2MDvoj4fl3ZikjY8Ld-dmv7i0,4089
5
- oldnews/data/__init__.py,sha256=pIkCj0LmMG2PckLWZ1ohDgIqgxqyx4o9tTo1oUnfauw,2098
6
- oldnews/data/auth.py,sha256=5CWu4kjEkyJ8TDqqIYkUNFAzebygpksKIPdFhT62uOM,1217
7
- oldnews/data/config.py,sha256=nhgPwKDSHQ5Fvi9u0o6lpCerglPuI7ImMzYRasbs1v4,3352
8
- oldnews/data/db.py,sha256=IN3TOORqLbd-c8jXnHIK0Y_WVWav7GdgxSUTeKYSp0Y,2793
9
- oldnews/data/dump.py,sha256=sgWz1HHJlxG_B8uDtwtt_TS1ulnP4yji3hK7iinMc7Q,2206
10
- oldnews/data/last_grab.py,sha256=9GYl_U0KdLrHiAHCb-c72uNMseKW7aQwJxLyGU3d574,1594
11
- oldnews/data/local_articles.py,sha256=6MnE0rDCib8XFZaiAmrdefb6qZySLlVJYaj89ulyu3Y,15099
12
- oldnews/data/local_folders.py,sha256=ku2-6XQb2SMZdqVJ7DOqDiAT8PtmqzU8W51TQSsYcvw,1560
13
- oldnews/data/local_subscriptions.py,sha256=2wZudEvykr1U1NYhdUUnR9u4r-eR8MGVzoi06qi9zI0,3766
14
- oldnews/data/local_unread.py,sha256=iXhiFbHG7_7EZHtaf8hxc07yOZKQu_JrjodNnMTIllg,1442
15
- oldnews/data/locations.py,sha256=rJqXy_15ok5G86XbrXmixyYTBLFO0V0BWD8rLKotuBg,1723
16
- oldnews/data/log.py,sha256=nd6w7NAiUzZjeVM4HZd-oWFFVyQvWblXjdRYlSjua5k,1211
17
- oldnews/data/navigation_state.py,sha256=bBu7swWDVMD52I3pBZbWLAxJNpm96aqDaMNVH16tKto,1319
18
- oldnews/data/reset.py,sha256=K-AqeEsj4CIMTK1yX-BTdTX0Eyg5bFG8wE2-qoMq5zo,765
19
- oldnews/data/tools.py,sha256=FzjcYB6xKFpW5_Rd-8VO3c-7VIeRZV8gj9qMRAEdlys,1390
20
- oldnews/oldnews.py,sha256=xdmm0UaLmPReZhDsjfMNeL_mHh2-rIs74gh3H1vqYZE,3871
21
- oldnews/providers/__init__.py,sha256=R_wS987EuI3KDiN9Xzf0P5wiRSYLOk_-3twvr2ML7WU,354
22
- oldnews/providers/main.py,sha256=kHyXfumWV6pZhLUfAe6LCsEYQmITYmV0RxXIn0qmlNs,2020
23
- oldnews/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- oldnews/screens/__init__.py,sha256=-Iif16T316dnZkgJjX1YE7e4v7FxI0k_V08qd5za0t8,330
25
- oldnews/screens/folder_input.py,sha256=i6KeRVD1Ucfg2T6VJmzdKKnUHf6qo_1ka0ZLlNMuabA,1869
26
- oldnews/screens/information_display.py,sha256=-qG1BJxnhF9HtaP8d_HIuRzwMlAwl5raCLIAFpIDODg,2543
27
- oldnews/screens/login.py,sha256=a2hUERxpKYg7GQIYlpyDgHTAUEKmsANjwHZx1r-gXSw,3377
28
- oldnews/screens/main.py,sha256=lV62hmWbxn3Iq90gcGyEmX8X2zM7fQUvZVVo-8EcFHY,28766
29
- oldnews/screens/new_subscription.py,sha256=bk01RXWu3kvJbtm88o1mrYpll73Op3PWWl7ggIH29kk,4011
30
- oldnews/screens/process_subscription.py,sha256=8Z7aJLx-KkItaCQXfgf44cOQ83AZPlRJcMxFDuaHk54,2891
31
- oldnews/sync.py,sha256=iZbVniwhTTvZmLBGvwviG3wV-lyOBXEPQpm2xgiTeo8,11150
32
- oldnews/widgets/__init__.py,sha256=5VSjKswHxv2W8g0O-LWlUFS-gy7iQrIM8PGvSBhDNLU,438
33
- oldnews/widgets/_next_matching_option.py,sha256=rKGyIcj_wUcGZEeQJ1QAJmVke1XRsDpNRy9GS7PZEYo,1600
34
- oldnews/widgets/article_content.py,sha256=pv8zobd3eTsALHYmP854dd_enqy32QXGoWXEILYnWfA,3553
35
- oldnews/widgets/article_list.py,sha256=586r4LLeQbNhamO4pEe0cj_nHDvctPmJTmTw4amHoEM,7372
36
- oldnews/widgets/navigation.py,sha256=IWlET89rcXw99sNX2at1Zi76EKVADMfm-MzaG_XfCl4,12698
37
- oldnews-0.8.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
38
- oldnews-0.8.0.dist-info/entry_points.txt,sha256=FxY6Y4IsHZubhtdd0QJG3p2kCTcXe0e-Ib_AW0qkotE,51
39
- oldnews-0.8.0.dist-info/METADATA,sha256=_9fxAFDTm7UlU8AHPV4wkRHdtIi-TTpS9pRkOwC5byQ,2951
40
- oldnews-0.8.0.dist-info/RECORD,,