jaseci 1.4.0.16__py3-none-any.whl → 1.4.0.18__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.

Potentially problematic release.


This version of jaseci might be problematic. Click here for more details.

jaseci/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0.16
1
+ 1.4.0.18
@@ -26,3 +26,19 @@ class WebtoolTest(CoreTest):
26
26
  @jac_testcase("webtool.jac", "get_meta_invalid")
27
27
  def test_get_meta_invalid(self, ret):
28
28
  self.assertTrue("Failed at getting metadata" in ret["report"][0])
29
+
30
+ @jac_testcase("webtool.jac", "get_meta_timeout")
31
+ def test_get_meta_timeout(self, ret):
32
+ self.assertTrue("Failed at getting metadata" in ret["report"][0])
33
+
34
+ @jac_testcase("webtool.jac", "get_meta_need_header")
35
+ def test_get_meta_need_header(self, ret):
36
+ self.assertTrue(ret["success"])
37
+ expected_tags = set(["og:image", "og:type", "og:title"])
38
+ tags = set(
39
+ [
40
+ meta["property"] if "property" in meta else ""
41
+ for meta in ret["report"][0]
42
+ ]
43
+ )
44
+ self.assertTrue(tags.issuperset(expected_tags))
@@ -5,13 +5,21 @@ from bs4 import BeautifulSoup
5
5
 
6
6
 
7
7
  @jaseci_action()
8
- def get_page_meta(url: str):
8
+ def get_page_meta(url: str, timeout: int = 3, parser: str = "lxml"):
9
9
  """
10
10
  Util to parse metadata out of urls and html documents
11
+ Parser option: lxml (default), html5lib, html.parser
12
+ Comparison between parsers: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser
11
13
  """
12
14
  try:
13
- webpage = requests.get(url)
14
- soup = BeautifulSoup(webpage.content, features="lxml")
15
+ webpage = requests.get(
16
+ url,
17
+ timeout=timeout,
18
+ headers={
19
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"
20
+ },
21
+ )
22
+ soup = BeautifulSoup(webpage.content, features=parser)
15
23
  meta = soup.find_all("meta")
16
24
  meta_list = []
17
25
  for tag in meta:
jaseci/utils/utils.py CHANGED
@@ -17,8 +17,9 @@ import traceback
17
17
  import inspect
18
18
  import unittest
19
19
  from time import time
20
-
20
+ from pathlib import Path
21
21
  from pprint import pformat
22
+ from typing import Union
22
23
 
23
24
  from jaseci.utils.log_utils import LimitedSlidingBuffer
24
25
 
@@ -331,3 +332,16 @@ def find_first_api(api_name, **api_endpoints):
331
332
  if api:
332
333
  return path, api
333
334
  raise InvalidApiException(f"api {api_name} is not existing!")
335
+
336
+
337
+ cache_root = Path(Path.home(), ".jaseci/models")
338
+
339
+
340
+ def model_base_path(cache_dir: Union[str, Path]) -> Path:
341
+ cache_dir = Path(cache_dir)
342
+
343
+ if not os.path.isabs(cache_dir):
344
+ model_cache = cache_root / cache_dir
345
+ else:
346
+ model_cache = cache_dir
347
+ return model_cache
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaseci
3
- Version: 1.4.0.16
3
+ Version: 1.4.0.18
4
4
  Home-page: https://github.com/Jaseci-Labs/jaseci
5
5
  Author: Jason Mars
6
6
  Author-email: jason@jaseci.org
@@ -31,4 +31,5 @@ Requires-Dist: pygls
31
31
  Requires-Dist: mock
32
32
  Requires-Dist: beautifulsoup4 (<4.13.0,>=4.12.2)
33
33
  Requires-Dist: lxml (<4.10.0,>=4.9.2)
34
+ Requires-Dist: html5lib (<1.2,>=1.1)
34
35
 
@@ -1,4 +1,4 @@
1
- jaseci/VERSION,sha256=dg0mtsTYEtoBjdH8cy9UJ_askmcWcS75Jlu9IOKgct4,9
1
+ jaseci/VERSION,sha256=wt2cDwcEID1HJJqP4EFUnrYbbWFI95p3NNCVHoBS-L4,9
2
2
  jaseci/__init__.py,sha256=qkJ3-ufZPGervTKYsKVNxdKvdMbrCmae8pgFAcWk5Pg,1101
3
3
  jaseci/cli_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  jaseci/cli_tools/book_tools.py,sha256=4xeNRhKufKJgAaKI5miPTezdBDWeA-iB_H5F5cqyIB8,16103
@@ -22,7 +22,7 @@ jaseci/extens/act_lib/stripe.py,sha256=Aal_0jmt8nGSWM4PFiKsSAXPN779d51nV-tnFr6_p
22
22
  jaseci/extens/act_lib/task.py,sha256=2OlsgYDprGyDwEzJ7943piqrqo7soCDBZRpqgGVMhUk,355
23
23
  jaseci/extens/act_lib/url.py,sha256=SC0fgrCA28UFznEAA_vOLnB51_N0MXU0801V_MVhDQg,1853
24
24
  jaseci/extens/act_lib/vector.py,sha256=ekTtYx3sHP6j23m1otVeKfqWynfLNsGg6271IIvfE-I,4636
25
- jaseci/extens/act_lib/webtool.py,sha256=YYZSaBWLUg646OX88_ZeB52AlfkFBsShk4PSA6F5Hv8,634
25
+ jaseci/extens/act_lib/webtool.py,sha256=1gJJJ8r86YQpRmSAY6_L6JUwLGl8ZcGWKtydSRemDnY,1038
26
26
  jaseci/extens/act_lib/zip.py,sha256=re6jUmkFZaOsrCpum8BMnLFltavrclv-rjfvhbl67i4,942
27
27
  jaseci/extens/act_lib/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  jaseci/extens/act_lib/tests/std_test_code.py,sha256=_pXoqkD4_s2LQHQBs_FFphYseJ5mCaPSe_LDvLW6p_Y,782
@@ -35,7 +35,7 @@ jaseci/extens/act_lib/tests/test_std.py,sha256=wSNganrnB7XVNYKBD8n2emXp1jrJJ5IiN
35
35
  jaseci/extens/act_lib/tests/test_std_lib.py,sha256=3RO3Q0y32A_D3bAokYRWSE8iHeyD2VRie8rmEpyZ9kM,1204
36
36
  jaseci/extens/act_lib/tests/test_url.py,sha256=TfCWRtSrB-wjDOxRpfT9yjkSVRW6Ro4_IynbPir00XM,904
37
37
  jaseci/extens/act_lib/tests/test_vector.py,sha256=Lte-EZnheAGiJUpCE0mlXzhCH3dTMW000pgYbiLeHtY,1285
38
- jaseci/extens/act_lib/tests/test_webtool.py,sha256=RbtT8wSR7p-07jxAuENmZSJqZV0YJ0UGg1Vmzg-eJzM,928
38
+ jaseci/extens/act_lib/tests/test_webtool.py,sha256=BfRQOdCUk3ciZj_wP6yzxVevcieqH5fQ6NhnbhllBH8,1529
39
39
  jaseci/extens/act_lib/tests/test_zlib.py,sha256=iG5FRkUsUDfJWKEhrgAJ21HWNZRfiWxGrctsZXpSxPw,840
40
40
  jaseci/extens/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  jaseci/extens/api/actions_api.py,sha256=Ml2wRROmXofEXWTOXy0PQCxRcjDLkxz163p7Z13zfKs,6923
@@ -159,14 +159,14 @@ jaseci/utils/id_list.py,sha256=L1uzwBrLRxnw3EaapOsEMA7QCsbY50RnK0nFTu2ruWo,5328
159
159
  jaseci/utils/json_handler.py,sha256=P1fY7BnGBfA_mkiKjeJvAwfqGXWt3cpY0JcmPVL86bQ,2135
160
160
  jaseci/utils/log_utils.py,sha256=U46KspmCbX6S7YzEk1LB20iB4G1DPHfpV5RFim04Mbg,1629
161
161
  jaseci/utils/test_core.py,sha256=DG0mW2GRc2l0M1A1-vCgTUFnZh8ip_0-h7eOfKMxlXQ,1549
162
- jaseci/utils/utils.py,sha256=-BBpaeZxVH3LgOHMrCO8R6S65Bm67FDoCLZr3aK39i8,8761
162
+ jaseci/utils/utils.py,sha256=iGK-Ovf5u9Y5cQUc95GJmyGpQQa1cnF7QOCseCf42EQ,9101
163
163
  jaseci/utils/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
164
  jaseci/utils/actions/actions_manager.py,sha256=sKfWk9zRpDpkLo3-mKpVMKrqx7kpRG7hRi5tfDTcqb8,8527
165
165
  jaseci/utils/actions/actions_optimizer.py,sha256=gs2spE-HFzdfW8WNqctw9DBldUxv3vj3DPpU5txZllE,20786
166
166
  jaseci/utils/actions/actions_state.py,sha256=5p080-DtDXS9QUd2FwkrtN6-7LBqT2tmJDOKVKjDEbU,2963
167
- jaseci-1.4.0.16.dist-info/LICENSE,sha256=2b_qOOd7ak6x49HwOzCAmRLSPJehiBJdqj9HDX1Jp7U,1072
168
- jaseci-1.4.0.16.dist-info/METADATA,sha256=JauKjHm-pvZgNW9fykwhejRHEYgbx2S0QF6TvgO26lY,1022
169
- jaseci-1.4.0.16.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
170
- jaseci-1.4.0.16.dist-info/entry_points.txt,sha256=nryZyKQLUJzlTOcA9knRGoXHGmNUCQxvvuDIEj5ePyg,88
171
- jaseci-1.4.0.16.dist-info/top_level.txt,sha256=0WZh7RF_ruiaZHQSi8IWOiLRUvKKDlhcnLe-by6EyFc,7
172
- jaseci-1.4.0.16.dist-info/RECORD,,
167
+ jaseci-1.4.0.18.dist-info/LICENSE,sha256=2b_qOOd7ak6x49HwOzCAmRLSPJehiBJdqj9HDX1Jp7U,1072
168
+ jaseci-1.4.0.18.dist-info/METADATA,sha256=wh0bSDOWuDVz46_MXv15eNHZM0NUbXw0VByq0TRUGO8,1059
169
+ jaseci-1.4.0.18.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
170
+ jaseci-1.4.0.18.dist-info/entry_points.txt,sha256=nryZyKQLUJzlTOcA9knRGoXHGmNUCQxvvuDIEj5ePyg,88
171
+ jaseci-1.4.0.18.dist-info/top_level.txt,sha256=0WZh7RF_ruiaZHQSi8IWOiLRUvKKDlhcnLe-by6EyFc,7
172
+ jaseci-1.4.0.18.dist-info/RECORD,,