Skip to content

Commit c63cd11

Browse files
committed
Adaptations following changes to express functionality
1 parent 1e6c0c9 commit c63cd11

6 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎examples/.env_example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OSW_WIKI_DOMAIN=wiki-dev.open-semantic-lab.org
2+
OSW_CRED_FILEPATH=/path/to/credentials/file
3+
OSW_DOWNLOAD_DIR=/path/to/download/directory

‎examples/get_page_content.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
go to special pages -> Bot passwords ; follow the instructions)
55
"""
66

7+
import dotenv
8+
79
from osw.express import OswExpress
810
from osw.params import GetPageParam
911

12+
dotenv.load_dotenv()
13+
1014
osw = OswExpress(domain="demo.open-semantic-lab.org")
1115

1216
# the page title of the page to downlaod

‎examples/inter_osw_copy_page.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
from pathlib import Path
55

6+
from opensemantic.v1 import OswBaseModel
67
from typing_extensions import List, Optional, Union
78

89
from osw.auth import CredentialManager
910
from osw.core import OSW
10-
from osw.model.static import OswBaseModel
1111
from osw.utils import util
1212
from osw.wtsite import SLOTS, WtPage, WtSite
1313

‎examples/offline_content_package.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import os
22
from pathlib import Path
33

4+
import dotenv
5+
46
from osw import wiki_tools
57
from osw.auth import CredentialManager
68
from osw.core import OSW
79
from osw.model.page_package import PagePackage, PagePackageBundle, PagePackageConfig
810
from osw.params import CreatePagePackageParam, PageDumpConfig
911
from osw.wtsite import WtSite
1012

13+
dotenv.load_dotenv()
14+
1115
# Create/update the password file under examples/accounts.pwd.yaml
1216
pwd_file_path = os.path.join(
1317
os.path.dirname(os.path.abspath(__file__)), "accounts.pwd.yaml"

‎examples/query_minimal.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import dotenv
2+
13
from osw.express import OswExpress
24

5+
dotenv.load_dotenv()
6+
37
# Create an OswExpress object
48
domain = "wiki-dev.open-semantic-lab.org"
59
osw = OswExpress(domain=domain)

‎examples/use_express_functions.py‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1+
import os
12
from pathlib import Path
23

3-
from osw.defaults import params as default_params
4-
from osw.defaults import paths as default_paths
5-
6-
# The domain, osw.express will be initialized with
7-
default_params.wiki_domain = "wiki-dev.open-semantic-lab.org"
4+
import dotenv
85

96
from osw.express import OswExpress, osw_download_file, osw_upload_file # noqa: E402
107

8+
# Best practise load environment variables from .env file
9+
dotenv.load_dotenv() # will look for a .env file in CWD and above
10+
11+
# (Alternative) Setting the domain of the wiki to connect to
12+
os.environ["OSW_WIKI_DOMAIN"] = "wiki-dev.open-semantic-lab.org"
1113
# (Optional) Set the default credentials filepath to desired location. Otherwise,
1214
# it will use the default location (current working directory)
13-
# cred_filepath_default.set_default(r"C:\Users\gold\ownCloud\Personal\accounts.pwd.yaml")
14-
15-
# Check setting
16-
print(f"Credentials loaded from '{str(default_paths.cred_filepath)}'")
15+
os.environ["OSW_CRED_FILEPATH"] = str(
16+
Path(__file__).parent / "osw_files" / "accounts.pwd.yaml"
17+
)
1718

1819
# The domain to connect to
1920
domain = "wiki-dev.open-semantic-lab.org"
2021
# domain = "demo.open-semantic-lab.org"
2122
# Create an OswExpress object
2223
osw_obj = OswExpress(domain=domain)
2324

25+
# (Alternative, here equivalent to) loading domain from the environment variable
26+
osw_obj = OswExpress()
27+
2428
# Create a file
2529
fp = Path("example.txt")
2630
with open(fp, "w") as file:

0 commit comments

Comments
 (0)