|
| 1 | +import os |
1 | 2 | from pathlib import Path |
2 | 3 |
|
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 |
8 | 5 |
|
9 | 6 | from osw.express import OswExpress, osw_download_file, osw_upload_file # noqa: E402 |
10 | 7 |
|
| 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" |
11 | 13 | # (Optional) Set the default credentials filepath to desired location. Otherwise, |
12 | 14 | # 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 | +) |
17 | 18 |
|
18 | 19 | # The domain to connect to |
19 | 20 | domain = "wiki-dev.open-semantic-lab.org" |
20 | 21 | # domain = "demo.open-semantic-lab.org" |
21 | 22 | # Create an OswExpress object |
22 | 23 | osw_obj = OswExpress(domain=domain) |
23 | 24 |
|
| 25 | +# (Alternative, here equivalent to) loading domain from the environment variable |
| 26 | +osw_obj = OswExpress() |
| 27 | + |
24 | 28 | # Create a file |
25 | 29 | fp = Path("example.txt") |
26 | 30 | with open(fp, "w") as file: |
|
0 commit comments