` by default.
85 | prefs['prefer_module_from_imports'] = False
86 |
87 | # If `True`, rope will transform a comma list of imports into
88 | # multiple separate import statements when organizing
89 | # imports.
90 | prefs['split_imports'] = False
91 |
92 | # If `True`, rope will remove all top-level import statements and
93 | # reinsert them at the top of the module when making changes.
94 | prefs['pull_imports_to_top'] = True
95 |
96 | # If `True`, rope will sort imports alphabetically by module name instead of
97 | # alphabetically by import statement, with from imports after normal
98 | # imports.
99 | prefs['sort_imports_alphabetically'] = False
100 |
101 | # Location of implementation of rope.base.oi.type_hinting.interfaces.ITypeHintingFactory
102 | # In general case, you don't have to change this value, unless you're an rope expert.
103 | # Change this value to inject you own implementations of interfaces
104 | # listed in module rope.base.oi.type_hinting.providers.interfaces
105 | # For example, you can add you own providers for Django Models, or disable the search
106 | # type-hinting in a class hierarchy, etc.
107 | prefs['type_hinting_factory'] = 'rope.base.oi.type_hinting.factory.default_type_hinting_factory'
108 |
109 |
110 | def project_opened(project):
111 | """This function is called after opening the project"""
112 | # Do whatever you like here!
113 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Main.py",
9 | "type": "python",
10 | "request": "launch",
11 | "stopOnEntry": false,
12 | "python": "${command:python.interpreterPath}",
13 | "program": "${workspaceFolder}\\example.py",
14 | "cwd": "${workspaceFolder}",
15 | "env": {},
16 | "envFile": "${workspaceFolder}/.env",
17 | "debugOptions": [
18 | "RedirectOutput"
19 | ]
20 | },
21 | ]
22 | }
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License(MIT)
2 |
3 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Copyleaks Python SDK
2 |
3 | Copyleaks SDK is a simple framework that allows you to scan textual content for plagiarism and trace content distribution online, using the [Copyleaks plagiarism checker cloud](https://api.copyleaks.com).
4 |
5 | Detect plagiarism using Copyleaks SDK in:
6 |
7 | * Online content and webpages
8 | * Local and cloud files ([see supported files](https://api.copyleaks.com/GeneralDocumentation/TechnicalSpecifications#supportedfiletypes"))
9 | * Free text
10 | * OCR (Optical Character Recognition) - scanning pictures with textual content ([see supported files](https://api.copyleaks.com/GeneralDocumentation/TechnicalSpecifications#supportedfiletypes))
11 |
12 | ### Installation
13 |
14 | Supported Python version: 3.
15 |
16 | You have two ways to integrate with the Copyleaks SDK:
17 |
18 | * **Recommended** - Use the Python Package Manager - [PiPy](https://pypi.python.org/pypi/copyleaks).
19 | When integrating this way you will automatically be able to update the SDK to its latest version:
20 |
21 | pip3 install copyleaks
22 |
23 |
24 | * Download the code from this repository and add it to your project.
25 |
26 | ### Register and Get Your API Key
27 |
28 | To use the Copyleaks SDK you need to have a Copyleaks account. The registration to Copyleaks is free of charge and quick. [Sign up](https://api.copyleaks.com/?register=true) and confirm your account to finalize your registration.
29 |
30 | Now, generate your personal API key on your [dashboard](https://api.copyleaks.com/dashboard) under 'API Access Credentials'.
31 |
32 | For more information check out our [API guide](https://api.copyleaks.com/documentation/v3).
33 |
34 | ### Examples
35 |
36 | See the [example.py](https://github.com/Copyleaks/Python-Plagiarism-Checker/blob/master/example.py) file.
37 |
38 | * To change the Identity server URI (default:"https://id.copyleaks.com"):
39 |
40 | Copyleaks.set_identity_uri("your identity server uri");
41 |
42 |
43 | * To change the API server URI (default:"https://api.copyleaks.com"):
44 |
45 | Copyleaks.set_api_uri("your api server uri");
46 |
47 |
48 | ### Dependencies
49 |
50 | pip3 install requests pytz python-dateutil
51 |
52 |
53 | ### Read More
54 |
55 | * [API Homepage](https://api.copyleaks.com)
56 | * [API Documentation](https://api.copyleaks.com/documentation)
57 | * [Plagiarism Report](https://github.com/Copyleaks/plagiarism-report)
58 |
--------------------------------------------------------------------------------
/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/__init__.py
--------------------------------------------------------------------------------
/copyleaks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/__init__.py
--------------------------------------------------------------------------------
/copyleaks/clients/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/clients/__init__.py
--------------------------------------------------------------------------------
/copyleaks/clients/ai_detection_client.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | The MIT License(MIT)
4 |
5 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 | '''
25 |
26 | import requests
27 | from copyleaks.consts import Consts
28 | from copyleaks.exceptions.command_error import CommandError
29 | from copyleaks.exceptions.under_maintenance_error import UnderMaintenanceError
30 | from copyleaks.helpers.copyleaks_client_helper import CopyleaksClientHelper
31 |
32 | class _AIDetectionClient:
33 | @staticmethod
34 | def __submit(url, auth_token, scan_id, submission):
35 | assert url and scan_id and submission
36 |
37 | CopyleaksClientHelper.verify_auth_token(auth_token)
38 |
39 | headers = {
40 | 'Content-Type': 'application/json',
41 | 'User-Agent': Consts.USER_AGENT,
42 | 'Authorization': f"Bearer {auth_token['access_token']}"
43 | }
44 | json = submission.toJSON()
45 | response = requests.post(url, headers=headers, data=json)
46 | if response.ok:
47 | return response.json()
48 | elif response.status_code == 503:
49 | raise UnderMaintenanceError()
50 | else:
51 | raise CommandError(response)
52 |
53 | @staticmethod
54 | def submit_natural_language(auth_token, scan_id, submission):
55 | '''
56 | Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
57 | This endpoint will receive submitted text to be checked. At the end of the processing stage,
58 | the result will be shown as classifications. Text classification is divided into sections.
59 | Each section may have a different classification
60 |
61 | Raises:
62 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
63 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
64 | '''
65 | url = f"{Consts.API_SERVER_URI}/v2/writer-detector/{scan_id}/check"
66 | return _AIDetectionClient.__submit(url, auth_token, scan_id, submission)
67 |
68 |
69 | @staticmethod
70 | def submit_source_code(auth_token, scan_id, submission):
71 | '''
72 | Use Copyleaks AI Content Detection to differentiate between human source code and AI written source code.
73 | This endpoint will receive submitted source code to be checked.
74 | At the end of the processing stage, the result will be shown as classifications.
75 | Source code classification is divided into sections. Each section may have a different classification.
76 |
77 | Raises:
78 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
79 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
80 | '''
81 | url = f"{Consts.API_SERVER_URI}/v2/writer-detector/source-code/{scan_id}/check"
82 | return _AIDetectionClient.__submit(url, auth_token, scan_id, submission)
83 |
--------------------------------------------------------------------------------
/copyleaks/clients/writing_assistant_client.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | The MIT License(MIT)
4 |
5 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 | '''
25 |
26 | import requests
27 | from copyleaks.consts import Consts
28 | from copyleaks.exceptions.command_error import CommandError
29 | from copyleaks.exceptions.under_maintenance_error import UnderMaintenanceError
30 | from copyleaks.helpers.copyleaks_client_helper import CopyleaksClientHelper
31 |
32 | class _WritingAssistantClient:
33 | @staticmethod
34 | def __submit(url, auth_token, scan_id, submission):
35 | assert url and scan_id and submission
36 |
37 | CopyleaksClientHelper.verify_auth_token(auth_token)
38 |
39 | headers = {
40 | 'Content-Type': 'application/json',
41 | 'User-Agent': Consts.USER_AGENT,
42 | 'Authorization': f"Bearer {auth_token['access_token']}"
43 | }
44 | json = submission.toJSON()
45 | response = requests.post(url, headers=headers, data=json)
46 | if response.ok:
47 | return response.json()
48 | elif response.status_code == 503:
49 | raise UnderMaintenanceError()
50 | else:
51 | raise CommandError(response)
52 |
53 | @staticmethod
54 | def submit_text(auth_token, scan_id, submission):
55 | '''
56 | Use Copyleaks Writing Assistant to generate grammar, spelling and sentence corrections for a given text.
57 | This endpoint will receive submitted text to be checked. The response will show the suggested corrections to the input text.
58 |
59 | Raises:
60 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
61 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
62 | '''
63 | url = f"{Consts.API_SERVER_URI}/v1/writing-feedback/{scan_id}/check"
64 | return _WritingAssistantClient.__submit(url, auth_token, scan_id, submission)
65 |
66 | @staticmethod
67 | def get_correction_types(language_code):
68 | '''
69 | Get a list of correction types supported within the Writing Assistant API.
70 | Correction types apply to all supported languages.
71 | The supplied language code for this request is used to determine the language of the texts returned.
72 |
73 | Raises:
74 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
75 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
76 |
77 | Returns:
78 | List of supported correction types.
79 | '''
80 |
81 | url = f"{Consts.API_SERVER_URI}/v1/writing-feedback/correction-types/{language_code}"
82 | headers = {
83 | 'User-Agent': Consts.USER_AGENT
84 | }
85 |
86 | response = requests.get(url, headers=headers)
87 | if response.ok:
88 | return response.json()
89 | elif response.status_code == 503:
90 | raise UnderMaintenanceError()
91 | else:
92 | raise CommandError(response.content)
93 |
--------------------------------------------------------------------------------
/copyleaks/consts.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Consts:
27 | API_SERVER_URI = 'https://api.copyleaks.com'
28 | IDENTITY_SERVER_URI = 'https://id.copyleaks.com'
29 |
30 | USER_AGENT = 'python-sdk/3.0'
31 |
--------------------------------------------------------------------------------
/copyleaks/copyleaks.py:
--------------------------------------------------------------------------------
1 | from copyleaks.consts import Consts
2 | import requests
3 | '''
4 | The MIT License(MIT)
5 |
6 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in all
16 | copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | SOFTWARE.
25 | '''
26 |
27 | import json
28 | from datetime import datetime, timedelta
29 | import dateutil.parser
30 | import pytz
31 | from copyleaks.exceptions.command_error import CommandError
32 | from copyleaks.exceptions.under_maintenance_error import UnderMaintenanceError
33 | from copyleaks.exceptions.rate_limit_error import RateLimitError
34 | from copyleaks.exceptions.auth_expired_error import AuthExipredError
35 | from enum import Enum
36 | from copyleaks.clients.ai_detection_client import _AIDetectionClient
37 | from copyleaks.clients.writing_assistant_client import _WritingAssistantClient
38 |
39 |
40 | class Copyleaks(object):
41 |
42 | WritingAssistantClient = _WritingAssistantClient
43 | AiDetectionClient = _AIDetectionClient
44 |
45 | @staticmethod
46 | def set_identity_uri(uri):
47 | '''
48 | Set the Identity server URI.
49 |
50 | Parameters:
51 | uri: string.
52 | '''
53 | Consts.IDENTITY_SERVER_URI = uri
54 |
55 | @staticmethod
56 | def set_api_uri(uri):
57 | '''
58 | Set the API server URI.
59 |
60 | Parameters:
61 | uri: string.
62 | '''
63 | Consts.API_SERVER_URI = uri
64 |
65 | @staticmethod
66 | def login(email, key):
67 | '''
68 | Login to Copyleaks authentication server.
69 | For more info: https://api.copyleaks.com/documentation/v3/account/login
70 |
71 | Parameters:
72 | email: string. Copyleaks account email address.
73 | key: string. Copyleaks account secret key.
74 |
75 | Raises:
76 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
77 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
78 |
79 | Returns:
80 | A authentication token that being expired after certain amount of time.
81 | '''
82 |
83 | assert email and key
84 |
85 | url = f"{Consts.IDENTITY_SERVER_URI}/v3/account/login/api"
86 | payload = {
87 | 'email': email,
88 | 'key': key
89 | }
90 |
91 | headers = {
92 | 'Content-Type': 'application/json',
93 | 'User-Agent': Consts.USER_AGENT
94 | }
95 |
96 | response = requests.post(url, headers=headers, data=json.dumps(payload))
97 | if response.ok:
98 | return response.json()
99 | elif response.status_code == 503:
100 | raise UnderMaintenanceError()
101 | else:
102 | raise CommandError(response)
103 |
104 | @staticmethod
105 | def verify_auth_token(auth_token):
106 | '''
107 | Verify that Copyleaks authentication token is exists and not expired.
108 |
109 | Parameters:
110 | auth_token: Copyleaks authentication token
111 |
112 | Raises:
113 | `AuthExipredError`: authentication expired. Need to login again.
114 | '''
115 | assert auth_token and auth_token['.expires'] and auth_token['access_token']
116 |
117 | now = pytz.UTC.localize(datetime.utcnow() + timedelta(0, 5 * 60)) # adds 5 minutes ahead for a safety shield.
118 | upTo = dateutil.parser.parse(auth_token['.expires'])
119 |
120 | if upTo <= now:
121 | raise AuthExipredError() # expired
122 |
123 | @staticmethod
124 | def __submit(url, auth_token, scan_id, submission):
125 | assert url and scan_id and submission
126 |
127 | Copyleaks.verify_auth_token(auth_token)
128 |
129 | headers = {
130 | 'Content-Type': 'application/json',
131 | 'User-Agent': Consts.USER_AGENT,
132 | 'Authorization': f"Bearer {auth_token['access_token']}"
133 | }
134 |
135 | response = requests.put(url, headers=headers, data=submission.toJSON())
136 | if response.ok:
137 | return # Completed successfully
138 | elif response.status_code == 503:
139 | raise UnderMaintenanceError()
140 | else:
141 | raise CommandError(response)
142 |
143 | @staticmethod
144 | def submit_file(auth_token, scan_id, submission):
145 | '''
146 | Starting a new process by providing a file to scan.
147 | For more info:
148 | https://api.copyleaks.com/documentation/v3/scans/submit/file
149 |
150 | Raises:
151 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
152 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
153 | '''
154 | url = f"{Consts.API_SERVER_URI}/v3/scans/submit/file/{scan_id}"
155 | Copyleaks.__submit(url, auth_token, scan_id, submission)
156 |
157 | @staticmethod
158 | def submit_file_ocr(auth_token, scan_id, submission):
159 | '''
160 | Starting a new process by providing a OCR image file to scan.
161 | For more info:
162 | https://api.copyleaks.com/documentation/v3/scans/submit/ocr
163 |
164 | Raises:
165 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
166 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
167 | '''
168 | url = f"{Consts.API_SERVER_URI}/v3/scans/submit/file/ocr/{scan_id}"
169 | Copyleaks.__submit(url, auth_token, scan_id, submission)
170 |
171 | @staticmethod
172 | def submit_url(auth_token, scan_id, submission):
173 | '''
174 | Starting a new process by providing a URL to scan.
175 | For more info:
176 | https://api.copyleaks.com/documentation/v3/scans/submit/url
177 |
178 | Raises:
179 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
180 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
181 | '''
182 | url = f"{Consts.API_SERVER_URI}/v3/scans/submit/url/{scan_id}"
183 | Copyleaks.__submit(url, auth_token, scan_id, submission)
184 |
185 | @staticmethod
186 | def export(auth_token, scan_id, export_id, model):
187 | '''
188 | Exporting scans artifact into your server.
189 | For more info:
190 | https://api.copyleaks.com/documentation/v3/downloads/export
191 |
192 | Parameters:
193 | auth_token: Your login token to Copyleaks server.
194 | scan_id: String. The scan ID of the specific scan to export.
195 | export_id: String. A new Id for the export process.
196 | model: `Export`. Request of which artifact should be exported.
197 |
198 | Raises:
199 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
200 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
201 | '''
202 | assert scan_id and export_id and model
203 |
204 | Copyleaks.verify_auth_token(auth_token)
205 |
206 | url = f"{Consts.API_SERVER_URI}/v3/downloads/{scan_id}/export/{export_id}"
207 |
208 | headers = {
209 | 'Content-Type': 'application/json',
210 | 'User-Agent': Consts.USER_AGENT,
211 | 'Authorization': f"Bearer {auth_token['access_token']}"
212 | }
213 |
214 | response = requests.post(url, headers=headers, data=model.toJSON())
215 | if response.ok:
216 | return # Completed successfully
217 | elif response.status_code == 503:
218 | raise UnderMaintenanceError()
219 | else:
220 | raise CommandError(response)
221 |
222 | @staticmethod
223 | def start(auth_token, model):
224 | '''
225 | Start scanning all the files you submitted for a price-check.
226 | For more info:
227 | https://api.copyleaks.com/documentation/v3/scans/start
228 |
229 | Parameters:
230 | auth_token: Your login token to Copyleaks server.
231 | model: `Start` object. Include information about which scans should be started.
232 |
233 | Raises:
234 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
235 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
236 |
237 | Returns:
238 | Server response including success/failed info.
239 | '''
240 | assert model
241 |
242 | Copyleaks.verify_auth_token(auth_token)
243 |
244 | url = f"{Consts.API_SERVER_URI}/v3/scans/start"
245 |
246 | headers = {
247 | 'Content-Type': 'application/json',
248 | 'User-Agent': Consts.USER_AGENT,
249 | 'Authorization': f"Bearer {auth_token['access_token']}"
250 | }
251 |
252 | response = requests.patch(url, headers=headers, data=model.toJSON())
253 | if response.ok:
254 | return response.json() # Completed successfully
255 | elif response.status_code == 503:
256 | raise UnderMaintenanceError()
257 | else:
258 | raise CommandError(response)
259 |
260 | @staticmethod
261 | def delete(auth_token, delete_model):
262 | '''
263 | Delete the specific process from the server.
264 | For more info:
265 | https://api.copyleaks.com/documentation/v3/scans/delete
266 |
267 | Raises:
268 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
269 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
270 | '''
271 | assert delete_model
272 |
273 | Copyleaks.verify_auth_token(auth_token)
274 |
275 | url = f"{Consts.API_SERVER_URI}/v3.1/scans/delete"
276 |
277 | headers = {
278 | 'Content-Type': 'application/json',
279 | 'User-Agent': Consts.USER_AGENT,
280 | 'Authorization': f"Bearer {auth_token['access_token']}"
281 | }
282 |
283 | response = requests.patch(url, headers=headers, data=delete_model.toJSON())
284 | if response.ok:
285 | return # Completed successfully
286 | elif response.status_code == 503:
287 | raise UnderMaintenanceError()
288 | else:
289 | raise CommandError(response)
290 |
291 | @staticmethod
292 | def resend_webhook(auth_token, scan_id):
293 | '''
294 | Resend status webhooks for existing scans.
295 | For more info:
296 | https://api.copyleaks.com/documentation/v3/scans/webhook-resend
297 |
298 | Raises:
299 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
300 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
301 | '''
302 | assert scan_id
303 |
304 | Copyleaks.verify_auth_token(auth_token)
305 |
306 | url = f"{Consts.API_SERVER_URI}/v3/scans/{scan_id}/webhooks/resend"
307 |
308 | headers = {
309 | 'Content-Type': 'application/json',
310 | 'User-Agent': Consts.USER_AGENT,
311 | 'Authorization': f"Bearer {auth_token['access_token']}"
312 | }
313 |
314 | response = requests.post(url, headers=headers)
315 | if response.ok:
316 | return # Completed successfully
317 | elif response.status_code == 503:
318 | raise UnderMaintenanceError()
319 | else:
320 | raise CommandError(response)
321 |
322 | @staticmethod
323 | def credits_balance(auth_token):
324 | '''
325 | Get current credits balance for the Copyleaks account
326 | For more info:
327 | https://api.copyleaks.com/documentation/v3/scans/credits
328 |
329 | Raises:
330 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
331 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
332 | `RateLimitError`: Too many requests. Please wait before calling again.
333 |
334 | Returns:
335 | Number of remaining credits on the account.
336 | '''
337 | Copyleaks.verify_auth_token(auth_token)
338 |
339 | url = f"{Consts.API_SERVER_URI}/v3/scans/credits"
340 | headers = {
341 | 'User-Agent': Consts.USER_AGENT,
342 | 'Authorization': f"Bearer {auth_token['access_token']}"
343 | }
344 |
345 | response = requests.get(url, headers=headers)
346 | if response.ok:
347 | return response.json()
348 | elif response.status_code == 503:
349 | raise UnderMaintenanceError()
350 | elif response.status_code == 429:
351 | raise RateLimitError()
352 | else:
353 | raise CommandError(response)
354 |
355 | @staticmethod
356 | def usages_history_csv(auth_token, start_date, end_date):
357 | '''
358 | This endpoint allows you to export your usage history between two dates.
359 | The output results will be exported to a csv file and it will be attached to the response.
360 | For more info:
361 | https://api.copyleaks.com/documentation/v3/scans/usages/history
362 |
363 | Parameters:
364 | auth_token: Your login token to Copyleaks server.
365 | start_date: String. The start date to collect usage history from. Date Format: `dd-MM-yyyy`
366 | end_date: String. The end date to collect usage history from. Date Format: `dd-MM-yyyy`
367 |
368 | Raises:
369 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
370 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
371 | `RateLimitError`: Too many requests. Please wait before calling again.
372 |
373 | Returns:
374 | Server response including success/failed info.
375 | '''
376 | assert start_date and end_date
377 |
378 | Copyleaks.verify_auth_token(auth_token)
379 |
380 | url = f"{Consts.API_SERVER_URI}/v3/scans/usages/history?start={start_date}&end={end_date}"
381 |
382 | headers = {
383 | 'Content-Type': 'application/json',
384 | 'User-Agent': Consts.USER_AGENT,
385 | 'Authorization': f"Bearer {auth_token['access_token']}"
386 | }
387 |
388 | response = requests.get(url, headers=headers)
389 | if response.ok:
390 | return response.content # Completed successfully
391 | elif response.status_code == 503:
392 | raise UnderMaintenanceError()
393 | elif response.status_code == 429:
394 | raise RateLimitError()
395 | else:
396 | raise CommandError(response)
397 |
398 | @staticmethod
399 | def release_notes():
400 | '''
401 | Get updates about copyleaks api release notes
402 | For more info: https://api.copyleaks.com/documentation/v3/release-notes
403 |
404 | Raises:
405 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
406 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
407 |
408 | Returns:
409 | List of release notes.
410 | '''
411 |
412 | url = f"{Consts.API_SERVER_URI}/v3/release-logs.json"
413 | headers = {
414 | 'User-Agent': Consts.USER_AGENT
415 | }
416 |
417 | response = requests.get(url, headers=headers)
418 | if response.ok:
419 | return response.json()
420 | elif response.status_code == 503:
421 | raise UnderMaintenanceError()
422 | else:
423 | raise CommandError(response)
424 |
425 | @staticmethod
426 | def supported_file_types():
427 | '''
428 | Get a list of the supported file types.
429 | For more info: https://api.copyleaks.com/documentation/v3/specifications/supported-file-types
430 |
431 | Raises:
432 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
433 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
434 |
435 | Returns:
436 | List of supported file types.
437 | '''
438 |
439 | url = f"{Consts.API_SERVER_URI}/v3/miscellaneous/supported-file-types"
440 | headers = {
441 | 'User-Agent': Consts.USER_AGENT
442 | }
443 |
444 | response = requests.get(url, headers=headers)
445 | if response.ok:
446 | return response.json()
447 | elif response.status_code == 503:
448 | raise UnderMaintenanceError()
449 | else:
450 | raise CommandError(response)
451 |
452 | @staticmethod
453 | def ocr_supported_langauges():
454 | '''
455 | Get a list of the supported languages for OCR (this is not a list of supported languages for the api, but only for the OCR files scan).
456 | For more info: https://api.copyleaks.com/documentation/v3/specifications/ocr-languages/list
457 |
458 | Raises:
459 | `CommandError`: Server reject the request. See response status code, headers and content for more info.
460 | `UnderMaintenanceError`: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: https://api.copyleaks.com/documentation/v3/exponential-backoff
461 |
462 | Returns:
463 | List of supported OCR languages.
464 | '''
465 |
466 | url = f"{Consts.API_SERVER_URI}/v3/miscellaneous/ocr-languages-list"
467 | headers = {
468 | 'User-Agent': Consts.USER_AGENT
469 | }
470 |
471 | response = requests.get(url, headers=headers)
472 | if response.ok:
473 | return response.json()
474 | elif response.status_code == 503:
475 | raise UnderMaintenanceError()
476 | else:
477 | raise CommandError(response)
478 |
--------------------------------------------------------------------------------
/copyleaks/exceptions/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/exceptions/__init__.py
--------------------------------------------------------------------------------
/copyleaks/exceptions/auth_expired_error.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class AuthExipredError(Exception):
27 | def __init__(self):
28 | pass
29 |
--------------------------------------------------------------------------------
/copyleaks/exceptions/command_error.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class CommandError(Exception):
27 | def __init__(self, response):
28 | self.__set_response(response)
29 |
30 | def get_response(self):
31 | return self.__x
32 |
33 | def __set_response(self, x):
34 | self.__x = x
35 |
--------------------------------------------------------------------------------
/copyleaks/exceptions/rate_limit_error.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class RateLimitError(Exception):
27 | def __init__(self):
28 | pass
29 |
--------------------------------------------------------------------------------
/copyleaks/exceptions/under_maintenance_error.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class UnderMaintenanceError(Exception):
27 | def __init__(self):
28 | pass
29 |
--------------------------------------------------------------------------------
/copyleaks/helpers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/helpers/__init__.py
--------------------------------------------------------------------------------
/copyleaks/helpers/copyleaks_client_helper.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime, timedelta
2 | import dateutil.parser
3 | import pytz
4 | from copyleaks.exceptions.auth_expired_error import AuthExipredError
5 |
6 | class CopyleaksClientHelper:
7 | @staticmethod
8 | def verify_auth_token(auth_token):
9 | '''
10 | Verify that Copyleaks authentication token is exists and not expired.
11 |
12 | Parameters:
13 | auth_token: Copyleaks authentication token
14 |
15 | Raises:
16 | `AuthExipredError`: authentication expired. Need to login again.
17 | '''
18 | assert auth_token and auth_token['.expires'] and auth_token['access_token']
19 |
20 | now = pytz.UTC.localize(datetime.utcnow() + timedelta(0, 5 * 60)) # adds 5 minutes ahead for a safety shield.
21 | upTo = dateutil.parser.parse(auth_token['.expires'])
22 |
23 | if upTo <= now:
24 | raise AuthExipredError() # expired
25 |
--------------------------------------------------------------------------------
/copyleaks/models/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/models/__init__.py
--------------------------------------------------------------------------------
/copyleaks/models/delete.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | import json
26 | from xmlrpc.client import Boolean
27 |
28 |
29 | class Delete:
30 | def get_scans(self):
31 | '''
32 | Scans to delete list.
33 | '''
34 | return self.scans
35 |
36 | def set_scans(self, value):
37 | '''
38 | Scans to delete list.
39 |
40 | Parameters:
41 | value: `DeleteScan` list.
42 | '''
43 |
44 | assert value
45 |
46 | self.scans = value
47 |
48 | def get_purge(self):
49 | '''
50 | Delete all trace of the scan from Copyleaks server, including from internal database. A purged process will not be available as a result for previous scans.
51 | '''
52 | return self.scans
53 |
54 | def set_purge(self, value):
55 | '''
56 | Delete all trace of the scan from Copyleaks server, including from internal database. A purged process will not be available as a result for previous scans.
57 |
58 | Parameters:
59 | value: Boolean.
60 | '''
61 |
62 | assert value != None and type(value) is Boolean
63 |
64 | self.purge = value
65 |
66 | def get_completion_webhook(self):
67 | '''
68 | Allows you to register to a webhook that will be fired once the removal has been completed.
69 | Make sure that your endpoint is listening to a POST method (no body parameters were supplied).
70 | '''
71 | return self.completionWebhook
72 |
73 | def set_completion_webhook(self, value):
74 | '''
75 | Allows you to register to a webhook that will be fired once the removal has been completed.
76 | Make sure that your endpoint is listening to a POST method (no body parameters were supplied).
77 |
78 | Parameters:
79 | value: String (uri).
80 | '''
81 |
82 | assert value
83 |
84 | self.completionWebhook = value
85 |
86 | def toJSON(self):
87 | return json.dumps(self, default=lambda o: o.__dict__,
88 | sort_keys=True, indent=4)
89 |
90 |
91 | class DeleteScan:
92 | def __init__(self, id):
93 | self.set_id(id)
94 |
95 | def get_id(self):
96 | '''
97 | Scan Id
98 | '''
99 | return self.id
100 |
101 | def set_id(self, value):
102 | '''
103 | Scan Id
104 |
105 | Parameters:
106 | value: String.
107 | '''
108 |
109 | assert value
110 |
111 | self.id = value
112 |
--------------------------------------------------------------------------------
/copyleaks/models/export.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | import json
26 | from abc import ABC
27 |
28 |
29 | class Export:
30 | def get_completion_webhook(self):
31 | '''
32 | Scan id to export.
33 | '''
34 | return self.completionWebhook
35 |
36 | def set_completion_webhook(self, value):
37 | '''
38 | Scan id to export.
39 |
40 | Parameters:
41 | value: String (uri).
42 | '''
43 |
44 | assert value
45 |
46 | self.completionWebhook = value
47 |
48 | def get_max_retries(self):
49 | '''
50 | How many retries to send before giving up.
51 | Using high value (12) may lead to a longer time until the completionWebhook being executed.
52 | A low value (1) may lead to errors while your service is temporary having problems.
53 | '''
54 | return self.maxRetries
55 |
56 | def set_max_retries(self, value):
57 | '''
58 | How many retries to send before giving up.
59 | Using high value (12) may lead to a longer time until the completionWebhook being executed.
60 | A low value (1) may lead to errors while your service is temporary having problems.
61 |
62 | Parameters:
63 | value: String (uri).
64 | '''
65 |
66 | assert value and value >= 1 and value <= 12
67 |
68 | self.maxRetries = value
69 |
70 | def get_developer_payload(self):
71 | '''
72 | Add a custom developer payload that will then be provided on the Export-Completed webhook.
73 | '''
74 | return self.developerPayload
75 |
76 | def set_developer_payload(self, value):
77 | '''
78 | Add a custom developer payload that will then be provided on the Export-Completed webhook.
79 |
80 | Parameters:
81 | value: String (uri).
82 | '''
83 |
84 | assert value and len(value) <= 512
85 |
86 | self.developerPayload = value
87 |
88 | def get_results(self):
89 | '''
90 | An list of results to be exported.
91 | '''
92 | return self.results
93 |
94 | def set_results(self, value):
95 | '''
96 | An list of results to be exported.
97 |
98 | Parameters:
99 | value: `ExportResult` list.
100 | '''
101 |
102 | assert value
103 |
104 | self.results = value
105 |
106 | def get_pdf_report(self):
107 | '''
108 | Download the PDF report. Allowed only when `properties.pdf.create` was set to true on the scan submittion.
109 | '''
110 | return self.pdfReport
111 |
112 | def set_pdf_report(self, value):
113 | '''
114 | Download the PDF report. Allowed only when `properties.pdf.create` was set to true on the scan submittion.
115 |
116 | Parameters:
117 | value: `ExportPdf`.
118 | '''
119 |
120 | assert value
121 |
122 | self.pdfReport = value
123 |
124 | def get_crawled_version(self):
125 | '''
126 | Download the crawled version of the submitted text.
127 | '''
128 | return self.crawledVersion
129 |
130 | def set_crawled_version(self, value):
131 | '''
132 | Download the crawled version of the submitted text.
133 |
134 | Parameters:
135 | value: `ExportCrawledVersion`.
136 | '''
137 |
138 | assert value
139 |
140 | self.crawledVersion = value
141 |
142 | def toJSON(self):
143 | return json.dumps(self, default=lambda o: o.__dict__,
144 | sort_keys=True, indent=4)
145 |
146 |
147 | class ExportItem(ABC):
148 | def get_endpoint(self):
149 | '''
150 | The HTTP url to upload the data.
151 | '''
152 | return self.endpoint
153 |
154 | def set_endpoint(self, value):
155 | '''
156 | The HTTP url to upload the data.
157 |
158 | Parameters:
159 | value: String.
160 | '''
161 |
162 | assert value
163 |
164 | self.endpoint = value
165 |
166 | def get_verb(self):
167 | '''
168 | The HTTP verb (also called "HTTP Methods") to upload the data to your specified endpoint.
169 | '''
170 | return self.verb
171 |
172 | def set_verb(self, value):
173 | '''
174 | The HTTP verb (also called "HTTP Methods") to upload the data to your specified endpoint.
175 |
176 | Parameters:
177 | value: String.
178 | '''
179 |
180 | assert value
181 |
182 | self.verb = value
183 |
184 | def get_headers(self):
185 | '''
186 | List of headers to be submitted with the upload request. You may use this field to provide additional request headers, such as "Authorization" header.
187 | '''
188 | return self.headers
189 |
190 | def set_headers(self, value):
191 | '''
192 | List of headers to be submitted with the upload request. You may use this field to provide additional request headers, such as "Authorization" header.
193 |
194 | Parameters:
195 | value: List of list of strings.
196 |
197 | Example:
198 | [["header-key1", "header-value1"], ["header-key2", "header-value2"]]
199 | '''
200 |
201 | assert value
202 |
203 | self.headers = value
204 |
205 |
206 | class ExportResult(ExportItem):
207 | def get_id(self):
208 | '''
209 | Result identification to be downloaded. You get these identifications from the completed webhook.
210 | '''
211 | return self.id
212 |
213 | def set_id(self, value):
214 | '''
215 | Result identification to be downloaded. You get these identifications from the completed webhook.
216 |
217 | Parameters:
218 | value: String.
219 | '''
220 |
221 | assert value
222 |
223 | self.id = value
224 |
225 |
226 | class ExportPdf(ExportItem):
227 | def __init__(self):
228 | pass
229 |
230 |
231 | class ExportCrawledVersion(ExportItem):
232 | def __init__(self):
233 | pass
234 |
--------------------------------------------------------------------------------
/copyleaks/models/start.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 | import json
27 |
28 |
29 | class Start:
30 | def get_trigger(self):
31 | '''
32 | A list of scans that you submitted for a check-credits scan and that you would like to submit for a full scan.
33 | '''
34 | return self.trigger
35 |
36 | def set_trigger(self, value):
37 | '''
38 | A list of scans that you submitted for a check-credits scan and that you would like to submit for a full scan.
39 |
40 | Parameters:
41 | value: String list.
42 | '''
43 | assert value
44 | self.trigger = value
45 |
46 | def get_error_handling(self):
47 | '''
48 | When set to ignore (ignore = 1) the trigger scans will start running even if some of them are in error mode, when set to cancel (cancel = 0) the request will be cancelled if any error was found.
49 | '''
50 | return self.errorHandling
51 |
52 | def set_error_handling(self, value):
53 | '''
54 | When set to ignore (ignore = 1) the trigger scans will start running even if some of them are in error mode, when set to cancel (cancel = 0) the request will be cancelled if any error was found.
55 |
56 | Parameters:
57 | value: `StartErrorHandling`.
58 | '''
59 | assert value in StartErrorHandling
60 |
61 | self.errorHandling = value
62 |
63 | def toJSON(self):
64 | return json.dumps(self, default=lambda o: o.__dict__,
65 | sort_keys=True, indent=4)
66 |
67 |
68 | class StartErrorHandling(IntEnum):
69 | Cancel = 0
70 | Ignore = 1
71 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/models/submit/__init__.py
--------------------------------------------------------------------------------
/copyleaks/models/submit/ai_detection_document.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from abc import ABC
26 | import json
27 |
28 | class AiDetectionDocument(ABC):
29 | def __init__(self, text):
30 | assert text
31 | self.text = text
32 |
33 | def get_text(self):
34 | return self.text
35 |
36 | def set_text(self, value):
37 | assert value
38 | self.text = value
39 |
40 | def get_sandbox(self):
41 | return self.sandbox
42 |
43 | def set_sandbox(self, value):
44 | self.sandbox = value
45 |
46 | def toJSON(self):
47 | return json.dumps(self, default=lambda o: o.__dict__,
48 | sort_keys=True, indent=4)
49 |
50 |
51 | class NaturalLanguageDocument(AiDetectionDocument):
52 | def __init__(self, text):
53 | super().__init__(text)
54 |
55 | def get_language(self):
56 | return self.language
57 |
58 | def set_language(self, value):
59 | self.language = value
60 |
61 |
62 | class SourceCodeDocument(AiDetectionDocument):
63 | def __init__(self, text, filename):
64 | super().__init__(text)
65 | self.filename = filename
66 |
67 | def get_filename(self):
68 | return self.filename
69 |
70 | def set_filename(self, value):
71 | assert value
72 | self.filename = value
73 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/document.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from abc import ABC
26 | import json
27 |
28 |
29 | class Document(ABC):
30 |
31 | def get_properties(self):
32 | return self.properties
33 |
34 | def set_properties(self, value):
35 | self.properties = value
36 |
37 | def toJSON(self):
38 | return json.dumps(self, default=lambda o: o.__dict__,
39 | sort_keys=True, indent=4)
40 |
41 |
42 | class FileDocument(Document):
43 | def __init__(self, base64, filename):
44 | self.set_base64(base64)
45 | self.set_filename(filename)
46 |
47 | def get_base64(self):
48 | return self.base64
49 |
50 | def set_base64(self, value):
51 | assert value
52 | self.base64 = value
53 |
54 | def get_filename(self):
55 | return self.filename
56 |
57 | def set_filename(self, value):
58 | assert value
59 | self.filename = value
60 |
61 |
62 | class OcrFileDocument(FileDocument):
63 | def get_language(self):
64 | return self.langCode
65 |
66 | def set_language(self, value):
67 | self.langCode = value
68 |
69 |
70 | class UrlDocument(Document):
71 | def get_url(self):
72 | return self.url
73 |
74 | def set_url(self, value):
75 | self.url = value
76 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Copyleaks/Python-Plagiarism-Checker/387325e09bca1a4389c4e6d79389c3737a918612/copyleaks/models/submit/properties/__init__.py
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/ai_generated_text.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class AIGeneratedText:
27 | def get_detect(self):
28 | '''
29 | Detects whether the text was written by an AI.
30 | '''
31 | return self.detect
32 |
33 |
34 | def set_detect(self, value):
35 | '''
36 | Set whether to detect AI Generated text.
37 |
38 | Parameters:
39 | value: Boolean.
40 | '''
41 | assert isinstance(value, bool)
42 |
43 | self.detect = value
44 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/author.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Author:
27 | def get_id(self):
28 | '''
29 | A unique identifier that represents the author of the content. Make sure to use the same ID for the same author.
30 | Using this feature Copyleaks can detect the author's writing patterns and get better results.
31 | '''
32 | return self.sensitivityLevel
33 |
34 | def set_id(self, value):
35 | '''
36 | A unique identifier that represents the author of the content. Make sure to use the same ID for the same author.
37 | Using this feature Copyleaks can detect the author's writing patterns and get better results.
38 |
39 | Parameters:
40 | value: Integer. Values between 1 to 5.
41 | '''
42 |
43 | assert value
44 |
45 | self.id = value
46 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/copyleaksDb.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class CopyleaksDb:
27 | def get_include_my_submissions(self):
28 | '''
29 | Get whether the document will be scanned against MY submittions in the copyleaks internal database.
30 | '''
31 | return self.includeMySubmissions
32 |
33 | def set_include_my_submissions(self, value):
34 | '''
35 | Compare the scanned document against MY submittions in the copyleaks internal database.
36 |
37 | Parameters:
38 | value: Boolean.
39 | '''
40 | assert isinstance(value, bool)
41 |
42 | self.includeMySubmissions = value
43 |
44 | def get_include_others_submissions(self):
45 | '''
46 | Get whether the document will be scanned against OTHER users submittions in the copyleaks internal database.
47 | '''
48 | return self.includeOthersSubmissions
49 |
50 | def set_include_others_submissions(self, value):
51 | '''
52 | Compare the scanned document against OTHER users submittions in the copyleaks internal database.
53 |
54 | Parameters:
55 | value: Boolean.
56 | '''
57 | assert isinstance(value, bool)
58 |
59 | self.includeOthersSubmissions = value
60 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/cross_languages.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class CrossLanguages:
27 | def get_languages(self):
28 | '''
29 | Get which languages would be svanned against the content.
30 | '''
31 | return self.languages
32 |
33 | def set_languages(self, value):
34 | '''
35 | Choose which languages to scan your content against.
36 | For each additional language chosen, your pages will be deducted per page submitted.
37 | The language of the original document submitted is always scanned,
38 | therefore should not be included in the additional languages chosen.
39 |
40 | value: `Language` array
41 | '''
42 | assert value
43 |
44 | self.languages = value
45 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/custom_metadata.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | class CustomMetadata:
26 | def get_key(self):
27 | return self.key
28 |
29 | def set_key(self, value):
30 | assert value
31 |
32 | self.key = value
33 |
34 | def get_value(self):
35 | return self.value
36 |
37 | def set_value(self, value):
38 | assert value
39 |
40 | self.value = value
41 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/domains_mode.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 |
27 |
28 | class DomainsMode(IntEnum):
29 | Include = 0
30 | Exclude = 1
31 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/exclude.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Exclude:
27 | def get_quotes(self):
28 | '''
29 | Exclude quoted text from the scan.
30 | '''
31 | return self.quotes
32 |
33 | def set_quotes(self, value):
34 | '''
35 | Exclude quoted text from the scan.
36 |
37 | Parameters:
38 | value: Boolean.
39 | '''
40 | assert isinstance(value, bool)
41 |
42 | self.quotes = value
43 |
44 | def get_references(self):
45 | '''
46 | Exclude referenced text from the scan.
47 | '''
48 | return self.references
49 |
50 | def set_references(self, value):
51 | '''
52 | Exclude referenced text from the scan.
53 |
54 | Parameters:
55 | value: Boolean.
56 | '''
57 | assert isinstance(value, bool)
58 |
59 | self.references = value
60 |
61 | def get_table_of_content(self):
62 | '''
63 | Exclude referenced text from the scan.
64 | '''
65 | return self.tableOfContents
66 |
67 | def set_table_of_content(self, value):
68 | '''
69 | Exclude referenced text from the scan.
70 |
71 | Parameters:
72 | value: Boolean.
73 | '''
74 | assert isinstance(value, bool)
75 |
76 | self.tableOfContents = value
77 |
78 | def get_titles(self):
79 | '''
80 | Exclude titles from the scan.
81 | '''
82 | return self.titles
83 |
84 | def set_titles(self, value):
85 | '''
86 | Exclude titles from the scan.
87 |
88 | Parameters:
89 | value: Boolean.
90 | '''
91 | assert isinstance(value, bool)
92 |
93 | self.titles = value
94 |
95 | def get_html_template(self):
96 | '''
97 | When the scanned document is an HTML document, exclude irrelevant text that appears across the site like the website footer or header.
98 | '''
99 | return self.htmlTemplate
100 |
101 | def set_html_template(self, value):
102 | '''
103 | When the scanned document is an HTML document, exclude irrelevant text that appears across the site like the website footer or header.
104 |
105 | Parameters:
106 | value: Boolean.
107 | '''
108 | assert isinstance(value, bool)
109 |
110 | self.htmlTemplate = value
111 |
112 | def get_citations(self):
113 | '''
114 | Get whether citations are excluded from the scan.
115 | '''
116 | return self.citations
117 |
118 | def set_citations(self, value):
119 | '''
120 | Set exclude citations from the scan.
121 |
122 | value: Boolean
123 | '''
124 | assert isinstance(value, bool)
125 |
126 | self.citations = value
127 |
128 |
129 | def get_document_template_ids(self):
130 | '''
131 | Get document template Ids.
132 | '''
133 | return self.documentTemplateIds
134 |
135 | def set_document_template_ids(self, value):
136 | '''
137 | Exclude text based on text found within other documents.
138 | Specify an array of scan ids containing text to exclude from your scan's text.
139 | Each scan ID specified should be in a completed success state and should not have expired at the time of submission.
140 |
141 | value: String array
142 | '''
143 | self.documentTemplateIds = value
144 |
145 |
146 | def get_code(self):
147 | '''
148 | Exclude sections of source code
149 | '''
150 | return self.code
151 |
152 | def set_code(self, value):
153 | '''
154 | set exclude code settings
155 |
156 | value: `ExcludeCode`
157 | '''
158 | assert value
159 |
160 | self.code = value
161 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/exclude_code.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class ExcludeCode:
27 | def get_comments(self):
28 | '''
29 | Get whether code comments are excluded
30 | '''
31 | return self.comments
32 |
33 | def set_comments(self, value):
34 | '''
35 | Set whether code comments should be excluded
36 |
37 | value: Boolean
38 | '''
39 | assert isinstance(value, bool)
40 |
41 | self.comments = value
42 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/filters.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from copyleaks.models.submit.properties.domains_mode import DomainsMode
26 |
27 |
28 | class Filters:
29 | def get_identical_enabled(self):
30 | '''
31 | Should enable matching of exact words in the text.
32 | '''
33 | return self.identicalEnabled
34 |
35 | def set_identical_enabled(self, value):
36 | '''
37 | Should enable matching of exact words in the text.
38 |
39 | Parameters:
40 | value: Boolean.
41 | '''
42 | assert value is not None
43 |
44 | self.identicalEnabled = value
45 |
46 | def get_minor_changes_enabled(self):
47 | '''
48 | Should enable matching of nearly identical words with small differences like "slow" becomes "slowly".
49 | '''
50 | return self.minorChangesEnabled
51 |
52 | def set_minor_changes_enabled(self, value):
53 | '''
54 | Should enable matching of nearly identical words with small differences like "slow" becomes "slowly".
55 |
56 | Parameters:
57 | value: Boolean.
58 | '''
59 | assert value is not None
60 |
61 | self.minorChangesEnabled = value
62 |
63 | def get_minor_changes_enabled(self):
64 | '''
65 | Should enable matching of paraphrased content stating similar ideas with different words.
66 | '''
67 | return self.relatedMeaningEnabled
68 |
69 | def set_related_meaning_enabled(self, value):
70 | '''
71 | Should enable matching of paraphrased content stating similar ideas with different words.
72 |
73 | Parameters:
74 | value: Boolean.
75 | '''
76 | assert value is not None
77 |
78 | self.relatedMeaningEnabled = value
79 |
80 | def get_min_copied_words(self):
81 | '''
82 | Select results with at least N copied words.
83 | '''
84 | return self.minCopiedWords
85 |
86 | def set_min_copied_words(self, value):
87 | '''
88 | Select results with at least N copied words.
89 |
90 | Parameters:
91 | value: Unsigned Integer.
92 | '''
93 | assert value
94 |
95 | self.minCopiedWords = value
96 |
97 | def get_safe_search(self):
98 | '''
99 | Block explicit adult content from the scan results such as web pages containing inappropriate images and videos.
100 | `SafeSearch` is not 100% effective with all websites.
101 | '''
102 | return self.safeSearch
103 |
104 | def set_safe_search(self, value):
105 | '''
106 | Block explicit adult content from the scan results such as web pages containing inappropriate images and videos.
107 | `SafeSearch` is not 100% effective with all websites.
108 |
109 | Parameters:
110 | value: Boolean.
111 | '''
112 | assert isinstance(value, bool)
113 |
114 | self.safeSearch = value
115 |
116 | def get_domains(self):
117 | '''
118 | A list of domains to either include or exclude from the scan - depending on the value of `domainsMode`.
119 | '''
120 | return self.domains
121 |
122 | def set_domains(self, value):
123 | '''
124 | A list of domains to either include or exclude from the scan - depending on the value of `domainsMode`.
125 |
126 | Parameters:
127 | value: String array.
128 | '''
129 | assert value
130 |
131 | self.domains = value
132 |
133 | def get_domains_mode(self):
134 | '''
135 | "Include" or "Exclude" the list of domains you specified under the domains property
136 | '''
137 | return self.domainsMode
138 |
139 | def set_domains_mode(self, value):
140 | '''
141 | "Include" or "Exclude" the list of domains you specified under the domains property
142 |
143 | Parameters:
144 | value: `DomainsMode` enum.
145 | '''
146 | assert value in DomainsMode
147 |
148 | self.domainsMode = value
149 |
150 | def get_allow_same_domain(self):
151 | '''
152 | when set to true it will allow results from the same domain as the submitted url.
153 | '''
154 | return self.identicalEnabled
155 |
156 | def set_allow_same_domain(self, value):
157 | '''
158 | when set to true it will allow results from the same domain as the submitted url.
159 |
160 | Parameters:
161 | value: Boolean.
162 | '''
163 | assert value is not None
164 |
165 | self.allowSameDomain = value
166 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/indexing.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Indexing:
27 | def get_repositories(self):
28 | '''
29 | Specify which repositories to index the scanned document to.
30 | '''
31 | return self.repositories
32 |
33 | def set_repositories(self, value):
34 | '''
35 | Specify which repositories to index the scanned document to.
36 |
37 | Parameters:
38 | value: `Repository` list.
39 | '''
40 |
41 | assert value
42 |
43 | self.repositories = value
44 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/language.py:
--------------------------------------------------------------------------------
1 | class Language:
2 | def get_code(self):
3 | '''
4 | Get language code for cross language plagiarism detection.
5 | '''
6 | return self.code
7 |
8 | def set_code(self, value):
9 | '''
10 | Set language code for cross language plagiarism detection.
11 |
12 | value: string
13 | '''
14 | assert value
15 |
16 | self.code = value
17 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/masking_policy.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 |
27 |
28 | class MaskingPolicy(IntEnum):
29 | NoMask = 0
30 | MaskOtherUsersFiles = 1
31 | MaskAllFiles = 2
32 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/pdf.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Pdf:
27 |
28 | def get_create(self):
29 | '''
30 | Returns whether to create PDF report or not.
31 | '''
32 | return self.create
33 |
34 | def set_create(self, value):
35 | '''
36 | Set whether to create PDF report or not.
37 |
38 | Parameters:
39 | value: Boolean.
40 | '''
41 | assert isinstance(value, bool)
42 |
43 | self.create = value
44 |
45 | def get_title(self):
46 | '''
47 | Customize the title for the PDF report.
48 | '''
49 | return self.title
50 |
51 | def set_title(self, value):
52 | '''
53 | Customize the title for the PDF report.
54 |
55 | Parameters:
56 | value: String.
57 | '''
58 | assert value
59 |
60 | self.title = value
61 |
62 | def get_large_logo_base64(self):
63 | '''
64 | Customize the logo image in the PDF report.
65 | '''
66 | return self.largeLogo
67 |
68 | def set_large_logo_base64(self, value):
69 | '''
70 | Customize the logo image in the PDF report.
71 |
72 | Parameters:
73 | value: String.
74 | '''
75 | assert value
76 |
77 | self.largeLogo = value
78 |
79 |
80 | def get_rtl(self):
81 | '''
82 | When set to true the text in the report will be aligned from right to left.
83 | '''
84 | return self.rtl
85 |
86 | def set_rtl(self, value):
87 | '''
88 | When set to true the text in the report will be aligned from right to left.
89 |
90 | Parameters:
91 | value: Boolean.
92 | '''
93 | assert isinstance(value, bool)
94 |
95 | self.rtl = value
96 |
97 |
98 | def get_version(self):
99 | '''
100 | Get PDF version to generate
101 | '''
102 | return self.version
103 |
104 | def set_version(self, value):
105 | '''
106 | Set PDF version to generate
107 |
108 | value: `PdfVersion` enum
109 | '''
110 | assert value
111 |
112 | self.version = value
113 |
114 |
115 | def get_report_customization_colors(self):
116 | '''
117 | Customizable colors
118 | '''
119 | return self.report_customization_colors
120 |
121 | def set_report_customization_colors(self, value):
122 | '''
123 | Set customizable colors
124 |
125 | value: `ReportCustomizationColors`
126 | '''
127 | assert value
128 |
129 | self.report_customization_colors = value
130 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/pdf_version.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 |
27 |
28 | class PdfVersion(IntEnum):
29 | V1 = 1
30 | V2 = 2
31 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/report_customization_colors.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | class ReportCustomizationColors:
26 | def get_main_strip(self):
27 | '''
28 | Get the color of the main strip in the header
29 | '''
30 | return self.mainStrip
31 |
32 | def set_main_strip(self, value):
33 | '''
34 | Set the color of the main strip in the header
35 |
36 | value: string
37 | '''
38 | assert value
39 |
40 | self.mainStrip = value
41 |
42 |
43 | def get_titles(self):
44 | '''
45 | Get the color for titles in copyleaks result report
46 | '''
47 | return self.titles
48 |
49 | def set_titles(self, value):
50 | '''
51 | Set the color for titles in copyleaks result report
52 |
53 | value: string
54 | '''
55 | assert value
56 |
57 | self.titles = value
58 |
59 |
60 | def get_identical(self):
61 | '''
62 | Get the highlight color for identical matches
63 | '''
64 | return self.identical
65 |
66 | def set_identical(self, value):
67 |
68 | '''
69 | Set the highlight color for identical matches
70 |
71 | value: string
72 | '''
73 | assert value
74 |
75 | self.identical = value
76 |
77 |
78 | def get_minor_changes(self):
79 | '''
80 | Get the highlight color for minor changes matches
81 | '''
82 | return self.minorChanges
83 |
84 | def set_minor_changes(self, value):
85 | '''
86 | Set the highlight color for minor changes matches
87 |
88 | value: string
89 | '''
90 | assert value
91 |
92 | self.minorChanges = value
93 |
94 | def get_related_meaning(self):
95 | '''
96 | Get the highlight color for related meaning matches
97 | '''
98 | return self.relatedMeaning
99 |
100 |
101 | def set_related_meaning(self, value):
102 | '''
103 | Set the highlight color for related meaning matches
104 |
105 | value: string
106 | '''
107 | assert value
108 |
109 | self.relatedMeaning = value
110 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/repository.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Repository:
27 | def get_id(self):
28 | '''
29 | Id of a repository to scan the submitted document against.
30 | '''
31 | return self.id
32 |
33 | def set_id(self, value):
34 | '''
35 | Id of a repository to scan the submitted document against.
36 |
37 | Parameters:
38 | value: String.
39 | '''
40 | assert value
41 |
42 | self.id = value
43 |
44 |
45 | class SearchRepository(Repository):
46 | def get_include_my_submissions(self):
47 | '''
48 | Compare the scanned document against MY submittions in the repository.
49 | '''
50 | return self.includeMySubmissions
51 |
52 | def set_include_my_submissions(self, value):
53 | '''
54 | Compare the scanned document against MY submittions in the repository.
55 |
56 | Parameters:
57 | value: Boolean.
58 | '''
59 | assert isinstance(value, bool)
60 |
61 | self.includeMySubmissions = value
62 |
63 | def get_include_others_submissions(self):
64 | '''
65 | Compare the scanned document against OTHER users submittions in the repository.
66 | '''
67 | return self.includeOthersSubmissions
68 |
69 | def set_include_others_submissions(self, value):
70 | '''
71 | Compare the scanned document against OTHER users submittions in the repository.
72 |
73 | Parameters:
74 | value: Boolean.
75 | '''
76 | assert isinstance(value, bool)
77 |
78 | self.includeOthersSubmissions = value
79 |
80 | class IndexingRepository(Repository):
81 | def get_masking_policy(self):
82 | '''
83 | Get the masking policy
84 | '''
85 | return self.maskingPolicy
86 |
87 | def set_masking_policy(self, value):
88 |
89 | '''
90 | allows to specify a document masking policy on the document level.
91 |
92 | If the repo has it's own masking policy, the stricter policy will be applied to results from this document.
93 |
94 | value: `MaskingPolicy` enum
95 | '''
96 | assert value
97 |
98 | self.maskingPolicy = value
99 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/scan_method.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 |
27 |
28 | class ScanMethodAlgorithm(IntEnum):
29 | MaximumCoverage = 0
30 | MaximumResults = 1
31 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/scan_properties.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | import abc
26 | from xmlrpc.client import Boolean
27 | from copyleaks.models.submit.properties.submit_action import SubmitAction
28 | from copyleaks.models.submit.properties.submit_webhooks import SubmitWebhooks
29 |
30 |
31 | class ScanProperties:
32 |
33 | def __init__(self, status_webhook):
34 | webhooks = SubmitWebhooks()
35 | webhooks.set_status(status_webhook)
36 | self.set_webhooks(webhooks)
37 |
38 |
39 | def get_action(self):
40 | '''
41 | Get the selected type of content submission action.
42 |
43 | Returns:
44 | Selected action from the type `SubmitAction`.
45 | '''
46 | return self.action
47 |
48 | def set_action(self, value):
49 | '''
50 | Set the submission action type.
51 |
52 | Parameters:
53 | value: `SubmitAction` enum.
54 | '''
55 | assert value != None
56 |
57 | self.action = value
58 |
59 | def get_include_html(self):
60 | '''
61 | Whether to include HTML version on the scan artifacts.
62 | '''
63 | return self.includeHtml
64 |
65 | def set_include_html(self, value):
66 | '''
67 | Change the value of the 'includeHtml' setting.
68 |
69 | Parameters:
70 | value: Boolean.
71 | '''
72 |
73 | assert isinstance(value, bool)
74 |
75 | self.includeHtml = value
76 |
77 | def get_developer_payload(self):
78 | '''
79 | Getting the developer payload.
80 | '''
81 | return self.developerPayload
82 |
83 | def set_developer_payload(self, value):
84 | '''
85 | Setting the developer payload parameter. This string must be no longer then 512 characters.
86 | '''
87 |
88 | assert value and len(value) <= 512
89 |
90 | self.developerPayload = value
91 |
92 |
93 | def get_sandbox(self):
94 | '''
95 | Get the sandbox mode status.
96 | '''
97 | return self.sandbox
98 |
99 | def set_sandbox(self, value):
100 | '''
101 | Change sandbox mode.
102 |
103 | Parameters:
104 | value: Boolean. To turn on, specify `True`. On production, choose `False`.
105 | '''
106 |
107 | assert value != None and type(value) is Boolean
108 |
109 | self.sandbox = value
110 |
111 | def get_expiration(self):
112 | '''
113 | Get the maximum life span of a scan in hours on the Copyleaks servers.
114 | '''
115 | return self.expiration
116 |
117 | def set_expiration(self, value):
118 | '''
119 | Specify the maximum life span of a scan in hours on the Copyleaks servers.
120 |
121 | Parameters:
122 | value: Positive integer between 1 to 2880 (4 months).
123 | '''
124 |
125 | assert value
126 |
127 | self.expiration = value
128 |
129 | def get_author(self):
130 | '''
131 | Metadata about the author.
132 | '''
133 | return self.author.id
134 |
135 | def set_author(self, value):
136 | '''
137 | Metadata about the author.
138 |
139 | Parameters:
140 | value: `Author`.
141 | '''
142 |
143 | assert value
144 |
145 | self.author = value
146 |
147 | def get_webhooks(self):
148 | '''
149 | Get webhooks configuration.
150 | '''
151 | return self.webhooks
152 |
153 | def set_webhooks(self, value):
154 | '''
155 | Set webhooks configuration.
156 |
157 | Parameters:
158 | value: `SubmitWebhooks`.
159 | '''
160 |
161 | assert value
162 |
163 | self.webhooks = value
164 |
165 | def get_filters(self):
166 | '''
167 | Get Copyleaks results filter preferences.
168 | '''
169 | return self.filters
170 |
171 | def set_filters(self, value):
172 | '''
173 | Set Copyleaks results filter preferences.
174 |
175 | Parameters:
176 | value: `Filters`.
177 | '''
178 |
179 | assert value
180 |
181 | self.filters = value
182 |
183 | def get_scanning(self):
184 | '''
185 | Get Copyleaks scanning preferences.
186 | '''
187 | return self.scanning
188 |
189 | def set_scanning(self, value):
190 | '''
191 | Set Copyleaks scanning preferences.
192 |
193 | Parameters:
194 | value: `Scanning`.
195 | '''
196 |
197 | assert value
198 |
199 | self.scanning = value
200 |
201 | def get_indexing(self):
202 | '''
203 | Get indexing policy settings.
204 | '''
205 | return self.indexing
206 |
207 | def set_indexing(self, value):
208 | '''
209 | Set indexing policy settings.
210 |
211 | Parameters:
212 | value: `Indexing`.
213 | '''
214 |
215 | assert value
216 |
217 | self.indexing = value
218 |
219 | def get_exclude(self):
220 | '''
221 | Which parts of the document won't be scanned.
222 | '''
223 | return self.exclude
224 |
225 | def set_exclude(self, value):
226 | '''
227 | Which parts of the document won't be scanned.
228 |
229 | Parameters:
230 | value: `Exclude`.
231 | '''
232 |
233 | assert value
234 |
235 | self.exclude = value
236 |
237 | def get_pdf(self):
238 | '''
239 | PDF report generation settings.
240 | '''
241 | return self.pdf
242 |
243 | def set_pdf(self, value):
244 | '''
245 | PDF report generation settings.
246 |
247 | Parameters:
248 | value: `Pdf`.
249 | '''
250 |
251 | assert value
252 |
253 | self.pdf = value
254 |
255 | def get_sensitivity_level(self):
256 | '''
257 | PDF report generation settings.
258 | '''
259 | return self.sensitivityLevel
260 |
261 | def set_sensitivity_level(self, value):
262 | '''
263 | You can control the level of plagiarism sensitivity that will be identified according to the speed of the scan. If you prefer a faster scan with the results that contains the highest amount of plagiarism choose 1, and if a slower, more comprehensive scan, that will also detect the smallest instances choose 5.
264 |
265 | Parameters:
266 | value: Integer. Values between 1 to 5.
267 | '''
268 |
269 | assert value and value >= 1 and value <= 5
270 |
271 | self.sensitivityLevel = value
272 |
273 | def get_cheat_detection(self):
274 | '''
275 | When set to true the submitted document will be checked for cheating. If a cheating will be detected, a scan alert will be added to the completed webhook.
276 | '''
277 | return self.cheatDetection
278 |
279 | def set_cheat_detection(self, value):
280 | '''
281 | When set to true the submitted document will be checked for cheating. If a cheating will be detected, a scan alert will be added to the completed webhook.
282 |
283 | Parameters:
284 | value: Boolean
285 | '''
286 |
287 | assert isinstance(value, bool)
288 |
289 | self.cheatDetection = value
290 |
291 | def get_scan_method_algorithm(self):
292 | '''
293 | Get scan algorithm goal.
294 | '''
295 | return self.scanMethodAlgorithm
296 |
297 |
298 | def set_scan_method_algorithm(self, value):
299 | '''
300 | Choose the algorithm goal. You can set this value depending on your use-case.
301 |
302 | Parameters:
303 | value: ScanMethodAlgorithm enum
304 | '''
305 | assert 0 <= value <= 1
306 |
307 | self.scanMethodAlgorithm = value
308 |
309 | def get_ai_generated_text(self):
310 | '''
311 | Ai Generated text settings.
312 | '''
313 | return self.aiGeneratedText
314 |
315 | def set_ai_generated_text(self, value):
316 | '''
317 | Ai Generated text settings.
318 |
319 | Parameters:
320 | value: `AIGeneratedText`
321 | '''
322 | assert value
323 | self.aiGeneratedText = value
324 |
325 | def get_custom_metadata(self):
326 | '''
327 | Get custom metadata
328 | '''
329 | return self.customMetadata
330 |
331 | def set_custom_metadata(self, value):
332 | '''
333 | Set custom properties that will be attached to your document in a Copyleaks repository.
334 |
335 | If this document is found as a repository result, your custom properties will be added to the result.
336 |
337 | value: `CustomMetadata` array
338 | '''
339 | assert value
340 | self.customMetadata = value
341 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/scanning.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class Scanning:
27 | def get_internet(self):
28 | '''
29 | Compare your content with online sources.
30 | '''
31 | return self.internet
32 |
33 | def set_internet(self, value):
34 | '''
35 | Compare your content with online sources.
36 |
37 | Parameters:
38 | value: Boolean.
39 | '''
40 | assert isinstance(value, bool)
41 |
42 | self.internet = value
43 |
44 | def get_exclude(self):
45 | '''
46 | Which results not to include on results.
47 | '''
48 | return self.exclude
49 |
50 | def set_exclude(self, value):
51 | '''
52 | Which results not to include on results.
53 |
54 | Parameters:
55 | value: `ScanningExclude`.
56 | '''
57 | assert value
58 |
59 | self.exclude = value
60 |
61 | def get_repositories(self):
62 | '''
63 | Specify which repositories to scan the document against.
64 | '''
65 | return self.repositories
66 |
67 | def set_repositories(self, value):
68 | '''
69 | Specify which repositories to scan the document against.
70 |
71 | Parameters:
72 | value: `SearchRepository` list.
73 | '''
74 | assert value
75 |
76 | self.repositories = value
77 |
78 | def get_copyleaks_db(self):
79 | '''
80 | Searching against Copyleaks DB source policy.
81 | '''
82 | return self.copyleaksDb
83 |
84 | def set_copyleaks_db(self, value):
85 | '''
86 | Searching against Copyleaks DB source policy.
87 |
88 | Parameters:
89 | value: `ScanningCopyleaksDb`.
90 | '''
91 | assert value
92 |
93 | self.copyleaksDb = value
94 |
95 | def get_exclude(self):
96 | '''
97 | Defines which parts of the document won't be scan.
98 | '''
99 | return self.exclude
100 |
101 | def set_exclude(self, value):
102 | '''
103 | Defines which parts of the document won't be scan.
104 |
105 | Parameters:
106 | value: `Exclude`.
107 | '''
108 | assert value
109 |
110 | self.exclude = value
111 |
112 |
113 | def get_cross_languages(self):
114 |
115 | return self.cross_languages
116 |
117 | def set_cross_languages(self, value):
118 | '''
119 | Cross language plagiarism detection. Choose which languages to scan your content against.
120 | For each additional language chosen, your pages will be deducted per page submitted.
121 | The language of the original document submitted is always scanned,
122 | therefore should not be included in the additional languages chosen.
123 |
124 | value: Language array
125 | '''
126 | assert value
127 |
128 | self.cross_languages = value
129 |
130 |
131 | def get_copylekas_db(self):
132 |
133 | return self.copyleaksDb
134 |
135 | def set_copylekas_db(self, value):
136 |
137 | assert value
138 |
139 | self.copyleaksDb = value
140 |
141 |
142 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/scanning_exclude.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class ScanningExclude:
27 | def get_id_pattern(self):
28 | '''
29 | Exclude your submissions from results if their id matches the supplied pattern. Matched submissions will be excluded from batch, internal database and repositories results.
30 | '''
31 | return self.idPattern
32 |
33 | def set_id_pattern(self, value):
34 | '''
35 | Exclude your submissions from results if their id matches the supplied pattern. Matched submissions will be excluded from batch, internal database and repositories results.
36 |
37 | Parameters:
38 | value: Boolean.
39 | '''
40 | assert isinstance(value, bool)
41 |
42 | self.idPattern = value
43 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/submit_action.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | from enum import IntEnum
26 |
27 |
28 | class SubmitAction(IntEnum):
29 | Scan = 0
30 | CheckCredits = 1
31 | Index = 2
32 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/properties/submit_webhooks.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class SubmitWebhooks:
27 | def get_new_result(self):
28 | '''
29 | Get the HTTP new result webhook URL.
30 | '''
31 | return self.newResult
32 |
33 | def set_new_result(self, value):
34 | '''
35 | Set the HTTP endpoint to be triggered while the scan is still running and a new result is found.
36 |
37 | Parameters:
38 | value: string(url).
39 | '''
40 | assert value
41 |
42 | self.newResult = value
43 |
44 | def get_status(self):
45 | '''
46 | Get the scan status changed webhook URL.
47 | '''
48 |
49 | return self.status
50 |
51 | def set_status(self, value):
52 | '''
53 | Set the webhook event that triggered once the scan status changes.
54 |
55 | Parameters:
56 | value: string(url).
57 | '''
58 | assert value
59 |
60 | self.status = value
61 |
62 | def get_status_headers(self):
63 | '''
64 | Get the headers for the status webhook.
65 | '''
66 | return self.statusHeaders
67 |
68 | def set_status_headers(self, value):
69 | '''
70 | Parameters:
71 | value: List of list of strings.
72 |
73 | Example:
74 | [["header-key1", "header-value1"], ["header-key2", "header-value2"]]
75 | '''
76 | assert isinstance(value, list)
77 | self.statusHeaders = value
78 |
79 | def get_new_result_headers(self):
80 | '''
81 | Get the headers for the new result webhook.
82 | '''
83 | return self.newResultHeaders
84 |
85 | def set_new_result_headers(self, value):
86 | '''
87 | Set the headers for the new result webhook.
88 |
89 | Parameters:
90 | value: List of list of strings.
91 |
92 | Example:
93 | [["header-key1", "header-value1"], ["header-key2", "header-value2"]]
94 | '''
95 | assert isinstance(value, list)
96 | self.newResultHeaders = value
97 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/scanning_copyleaks_db.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 |
26 | class ScanningCopyleaksDb:
27 | def get_include_my_submissions(self):
28 | '''
29 | When set to true: Copyleaks will also compare against content which was uploaded by YOU to the Copyleaks internal database.
30 | If true, it will also index the scan in the Copyleaks internal database.
31 | '''
32 | return self.includeMySubmissions
33 |
34 | def set_include_my_submissions(self, value):
35 | '''
36 | When set to true: Copyleaks will also compare against content which was uploaded by YOU to the Copyleaks internal database.
37 | If true, it will also index the scan in the Copyleaks internal database.
38 |
39 | Parameters:
40 | value: Boolean.
41 | '''
42 | assert isinstance(value, bool)
43 |
44 | self.includeMySubmissions = value
45 |
46 | def get_include_others_submissions(self):
47 | '''
48 | When set to true: Copyleaks will also compare against content which was uploaded by OTHERS to the Copyleaks internal database.
49 | If true, it will also index the scan in the Copyleaks internal database.
50 | '''
51 | return self.includeOthersSubmissions
52 |
53 | def set_include_others_submissions(self, value):
54 | '''
55 | When set to true: Copyleaks will also compare against content which was uploaded by OTHERS to the Copyleaks internal database.
56 | If true, it will also index the scan in the Copyleaks internal database.
57 |
58 | Parameters:
59 | value: Boolean.
60 | '''
61 | assert isinstance(value, bool)
62 |
63 | self.includeOthersSubmissions = value
64 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/score_weights.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | class ScoreWeights:
26 | def get_grammar_score_weight(self):
27 | return self.grammarScoreWeight
28 |
29 | def set_grammar_score_weight(self, value):
30 | assert value
31 | self.grammarScoreWeight = value
32 |
33 | def get_mechanics_score_weight(self):
34 | return self.mechanicsScoreWeight
35 |
36 | def set_mechanics_score_weight(self, value):
37 | assert value
38 | self.mechanicsScoreWeight = value
39 |
40 | def get_sentence_structure_score_weight(self):
41 | return self.sentenceStructureScoreWeight
42 |
43 | def set_sentence_structure_score_weight(self, value):
44 | assert value
45 | self.sentenceStructureScoreWeight = value
46 |
47 | def get_word_choice_score_weight(self):
48 | return self.wordChoiceScoreWeight
49 |
50 | def set_word_choice_score_weight(self, value):
51 | self.wordChoiceScoreWeight = value
52 | assert value
53 |
--------------------------------------------------------------------------------
/copyleaks/models/submit/writing_assistant_document.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | import json
26 |
27 | class WritingAssistantDocument():
28 |
29 | def __init__(self, text):
30 | assert text
31 | self.text = text
32 |
33 | def get_text(self):
34 | return self.text
35 |
36 | def set_text(self, value):
37 | assert value
38 | self.text = value
39 |
40 | def get_sandbox(self):
41 | return self.sandbox
42 |
43 | def set_sandbox(self, value):
44 | assert value
45 | self.sandbox = value
46 |
47 | def get_language(self):
48 | return self.language
49 |
50 | def set_language(self, value):
51 | assert value
52 | self.language = value
53 |
54 | def get_score(self):
55 | return self.score
56 |
57 | def set_score(self, value):
58 | assert value
59 | self.score = value
60 |
61 | def toJSON(self):
62 | return json.dumps(self, default=lambda o: o.__dict__,
63 | sort_keys=True, indent=4)
64 |
--------------------------------------------------------------------------------
/example.py:
--------------------------------------------------------------------------------
1 | '''
2 | The MIT License(MIT)
3 |
4 | Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | '''
24 |
25 | import base64
26 | import random
27 | from copyleaks.copyleaks import Copyleaks
28 | from copyleaks.exceptions.command_error import CommandError
29 | from copyleaks.models.submit.ai_detection_document import NaturalLanguageDocument, SourceCodeDocument
30 | from copyleaks.models.submit.document import FileDocument, UrlDocument, OcrFileDocument
31 | from copyleaks.models.submit.properties.scan_properties import ScanProperties
32 | from copyleaks.models.export import *
33 | from copyleaks.models.submit.score_weights import ScoreWeights
34 | from copyleaks.models.submit.writing_assistant_document import WritingAssistantDocument
35 | # Register on https://api.copyleaks.com and grab your secret key (from the dashboard page).
36 | EMAIL_ADDRESS = 'your@email.addresss'
37 | KEY = '00000000-0000-0000-0000-000000000000'
38 |
39 | try:
40 | auth_token = Copyleaks.login(EMAIL_ADDRESS, KEY)
41 | except CommandError as ce:
42 | response = ce.get_response()
43 | print(f"An error occurred (HTTP status code {response.status_code}):")
44 | print(response.content)
45 | exit(1)
46 |
47 | print("Logged successfully!\nToken:")
48 | print(auth_token)
49 |
50 |
51 | # This example is going to scan a FILE for plagiarism.
52 | # Alternatively, you can scan a URL using the class `UrlDocument`.
53 |
54 | print("Submitting a new file...")
55 | BASE64_FILE_CONTENT = base64.b64encode(b'Hello world').decode('utf8') # or read your file and convert it into BASE64 presentation.
56 | FILENAME = "hello.txt"
57 | scan_id = random.randint(100, 100000) # generate a random scan id
58 | file_submission = FileDocument(BASE64_FILE_CONTENT, FILENAME)
59 | # Once the scan completed on Copyleaks servers, we will trigger a webhook that notify you.
60 | # Write your public endpoint server address. If you testing it locally, make sure that this endpoint
61 | # is publicly available.
62 | scan_properties = ScanProperties('https://your.server/webhook?event={{STATUS}}')
63 | scan_properties.set_sandbox(True) # Turn on sandbox mode. Turn off on production.
64 | file_submission.set_properties(scan_properties)
65 | Copyleaks.submit_file(auth_token, scan_id, file_submission) # sending the submission to scanning
66 | print("Send to scanning")
67 | print("You will notify, using your webhook, once the scan was completed.")
68 |
69 | # Wait for completion webhook arrival...
70 | # Read more: https://api.copyleaks.com/documentation/v3/webhooks
71 | # Uncomment the following code to create an export task:
72 | # # Once the webhooks arrived and the scan was completed successfully (see the `status` flag) you can
73 | # # proceed to exporting all the artifacts related to your scan.
74 | # export = Export()
75 | # export.set_completion_webhook('https://your.server/webhook/export/completion')
76 | # crawled = ExportCrawledVersion() # Uncomment if you want to download the crawled version of your submitted document.
77 | # crawled.set_endpoint('https://your.server/webhook/export/crawled')
78 | # crawled.set_verb('POST')
79 | # crawled.set_headers([['key', 'value'], ['key2', 'value2']]) # optional
80 | # export.set_crawled_version(crawled)
81 |
82 | # # For each of the results in the Completed Webhook, you will get a unique `id`.
83 | # # In the following example we will export 2 results from Copyleaks's servers:
84 | # results1 = ExportResult()
85 | # results1.set_id('2b42c39fba') # change with your result id
86 | # results1.set_endpoint('https://your.server/webhook/export/result/2b42c39fba')
87 | # results1.set_verb('POST')
88 | # results1.set_headers([['key', 'value'], ['key2', 'value2']])
89 |
90 | # results2 = ExportResult()
91 | # results2.set_id('08338e505d') # change with your result id
92 | # results2.set_endpoint('https://your.server/webhook/export/result/08338e505d')
93 | # results2.set_verb('POST')
94 | # results2.set_headers([['key', 'value'], ['key2', 'value2']])
95 |
96 | # export.set_results([results1, results2])
97 |
98 | # Copyleaks.export(auth_token, scan_id, 'export-id', export) # 'export-id' value determind by you.
99 |
100 | # Wait while Copyleaks servers exporting artifacts...
101 | # Once process completed, you will get the "Export Completed" webhook.
102 | # Read more: https://api.copyleaks.com/documentation/v3/webhooks/export-completed
103 |
104 | # # For Repositories:
105 | # repo = SearchRepository()
106 | # repo.set_include_my_submissions(True)
107 | # repo.set_include_others_submissions(True)
108 | # repo.set_id("ID_FETCHED_DASHBOARD")
109 | # scan_properties.set_scanning(Scanning().set_repositories(repo))
110 |
111 | # # generate a pdf report:
112 | #pdf = Pdf() # Creating instance of Pdf.
113 | #pdf.set_create(True) # Setting the create pdf to True to generate PDF report.
114 | #scan_properties.set_pdf(pdf) # Will generate PDF report.
115 |
116 |
117 | # This example is going to use the AI detector client to detect ai in text
118 | sample_text = "Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures."
119 | natural_language_submission = NaturalLanguageDocument(sample_text)
120 | natural_language_submission.set_sandbox(True)
121 | response = Copyleaks.AiDetectionClient.submit_natural_language(auth_token, scan_id, natural_language_submission)
122 | print(response)
123 |
124 |
125 | # This example is going to use the AI detector client to detect ai in source code
126 | sample_code = (
127 | "def add(a, b):\n"
128 | " return a + b\n"
129 | "\n"
130 | "def multiply(a, b):\n"
131 | " return a * b\n"
132 | "\n"
133 | "def main():\n"
134 | " x = 5\n"
135 | " y = 10\n"
136 | " sum_result = add(x, y)\n"
137 | " product_result = multiply(x, y)\n"
138 | " print(f'Sum: {sum_result}')\n"
139 | " print(f'Product: {product_result}')\n"
140 | "\n"
141 | "if __name__ == '__main__':\n"
142 | " main()"
143 | )
144 | source_code_submission = SourceCodeDocument(sample_text, "example.py")
145 | source_code_submission.set_sandbox(True)
146 | response = Copyleaks.AiDetectionClient.submit_natural_language(auth_token, scan_id, source_code_submission)
147 | print(response)
148 |
149 |
150 | # This example is going to use the WritingAssistant client to get feedback on text
151 | score_weight = ScoreWeights()
152 | score_weight.set_grammar_score_weight(0.2)
153 | score_weight.set_mechanics_score_weight(0.3)
154 | score_weight.set_sentence_structure_score_weight(0.5)
155 | score_weight.set_word_choice_score_weight(0.4)
156 | submission = WritingAssistantDocument(sample_text)
157 | submission.set_score(score_weight)
158 | submission.set_sandbox(True)
159 | response = Copyleaks.WritingAssistantClient.submit_text(auth_token, scan_id, submission)
160 | print(response)
161 |
--------------------------------------------------------------------------------