pythonanywhere-core 0.1.8__tar.gz → 0.1.9__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.
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/PKG-INFO +1 -1
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pyproject.toml +1 -1
- pythonanywhere_core-0.1.9/pythonanywhere_core/__init__.py +1 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/files.py +14 -6
- pythonanywhere_core-0.1.8/pythonanywhere_core/__init__.py +0 -1
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/LICENSE +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/README.rst +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/base.py +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/exceptions.py +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/schedule.py +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/students.py +0 -0
- {pythonanywhere_core-0.1.8 → pythonanywhere_core-0.1.9}/pythonanywhere_core/webapp.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.9'
|
|
@@ -55,6 +55,9 @@ class Files:
|
|
|
55
55
|
return f": {msg}"
|
|
56
56
|
return ""
|
|
57
57
|
|
|
58
|
+
def _make_sharing_url(self, sharing_url_suffix):
|
|
59
|
+
return urljoin(self.base_url.split("api")[0], sharing_url_suffix)
|
|
60
|
+
|
|
58
61
|
def path_get(self, path: str) -> Union[dict, bytes]:
|
|
59
62
|
"""Returns dictionary of directory contents when `path` is an
|
|
60
63
|
absolute path to of an existing directory or file contents if
|
|
@@ -116,16 +119,18 @@ class Files:
|
|
|
116
119
|
def sharing_post(self, path: str) -> Tuple[int, str]:
|
|
117
120
|
"""Starts sharing a file at `path`.
|
|
118
121
|
|
|
119
|
-
Returns a tuple with a
|
|
120
|
-
success, raises otherwise.
|
|
121
|
-
if file has been already shared."""
|
|
122
|
+
Returns a tuple with a message and sharing link on
|
|
123
|
+
success, raises otherwise. Message is "successfully shared" on success,
|
|
124
|
+
"was already shared" if file has been already shared."""
|
|
122
125
|
|
|
123
126
|
url = self.sharing_endpoint
|
|
124
127
|
|
|
125
128
|
result = call_api(url, "POST", json={"path": path})
|
|
126
129
|
|
|
127
130
|
if result.ok:
|
|
128
|
-
|
|
131
|
+
msg = {200: "was already shared", 201: "successfully shared"}[result.status_code]
|
|
132
|
+
sharing_url_suffix = result.json()["url"]
|
|
133
|
+
return msg, self._make_sharing_url(sharing_url_suffix)
|
|
129
134
|
|
|
130
135
|
raise PythonAnywhereApiException(
|
|
131
136
|
f"POST to {url} to share '{path}' failed, got {result}{self._error_msg(result)}"
|
|
@@ -140,8 +145,11 @@ class Files:
|
|
|
140
145
|
url = f"{self.sharing_endpoint}?path={path}"
|
|
141
146
|
|
|
142
147
|
result = call_api(url, "GET")
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
if result.ok:
|
|
149
|
+
sharing_url_suffix = result.json()["url"]
|
|
150
|
+
return self._make_sharing_url(sharing_url_suffix)
|
|
151
|
+
else:
|
|
152
|
+
return ""
|
|
145
153
|
|
|
146
154
|
def sharing_delete(self, path: str) -> int:
|
|
147
155
|
"""Stops sharing file at `path`.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.1.8'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|