camel-ai 0.2.49__py3-none-any.whl → 0.2.51__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 camel-ai might be problematic. Click here for more details.

@@ -0,0 +1,80 @@
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+ import platform
15
+ import re
16
+ import unicodedata
17
+
18
+ MAX_FILENAME_LENGTH = 255
19
+ WINDOWS_RESERVED = {
20
+ 'CON',
21
+ 'PRN',
22
+ 'AUX',
23
+ 'NUL',
24
+ 'COM1',
25
+ 'COM2',
26
+ 'COM3',
27
+ 'COM4',
28
+ 'LPT1',
29
+ 'LPT2',
30
+ 'LPT3',
31
+ }
32
+
33
+
34
+ def sanitize_filename(
35
+ url_name: str,
36
+ default: str = "index",
37
+ max_length: int = MAX_FILENAME_LENGTH,
38
+ ) -> str:
39
+ r"""Sanitize a URL path into a safe filename that is safe for
40
+ most platforms.
41
+
42
+ Args:
43
+ url_name (str): The URL path to sanitize.
44
+ default (str): Default name if sanitization results in empty string.
45
+ (default: :obj:`"index"`)
46
+ max_length (int): Maximum length of the filename.
47
+ (default: :obj:`MAX_FILENAME_LENGTH`)
48
+
49
+ Returns:
50
+ str: A sanitized filename safe for most platforms.
51
+ """
52
+ if max_length < 1:
53
+ raise ValueError(
54
+ f"`max_length` must be greater than " f"0, got {max_length}"
55
+ )
56
+
57
+ if not url_name:
58
+ return default
59
+
60
+ # Normalize Unicode characters by removing characters
61
+ # such as accents and special characters:
62
+ # café☕.txt -> cafe.txt
63
+ url_name = unicodedata.normalize('NFKD', url_name)
64
+ url_name = url_name.encode('ASCII', 'ignore').decode('ASCII')
65
+
66
+ # Replace special characters such as:
67
+ # Separators: my/file:name*.txt -> my_file_name.txt etc.
68
+ url_name = re.sub(r'[\\/:*?"<>|.]', '_', url_name)
69
+ url_name = re.sub(r'_+', '_', url_name) # Collapse multiple underscores
70
+ url_name = url_name.strip('_') # Remove leading/trailing underscores
71
+
72
+ # Handle empty result if all characters are invalid:
73
+ if not url_name:
74
+ return default
75
+
76
+ # Handle Windows reserved names
77
+ if platform.system() == "Windows" and url_name.upper() in WINDOWS_RESERVED:
78
+ url_name = f"_{url_name}"
79
+
80
+ return url_name[:max_length]
@@ -14,6 +14,7 @@
14
14
  from .base import BaseVerifier
15
15
  from .math_verifier import MathVerifier
16
16
  from .models import VerificationOutcome
17
+ from .physics_verifier import PhysicsVerifier
17
18
  from .python_verifier import PythonVerifier
18
19
 
19
20
  __all__ = [
@@ -21,4 +22,5 @@ __all__ = [
21
22
  "VerificationOutcome",
22
23
  "PythonVerifier",
23
24
  "MathVerifier",
25
+ "PhysicsVerifier",
24
26
  ]