(url: str)
| 234 | |
| 235 | |
| 236 | def generate_text_from_url(url: str): |
| 237 | text_file_path = None |
| 238 | raw_inputs = None |
| 239 | # for text str input |
| 240 | if not os.path.exists(url) and not url.startswith('http'): |
| 241 | raw_inputs = url |
| 242 | return text_file_path, raw_inputs |
| 243 | |
| 244 | # for local txt inputs |
| 245 | if os.path.exists(url) and (url.lower().endswith('.txt') |
| 246 | or url.lower().endswith('.scp')): |
| 247 | text_file_path = url |
| 248 | return text_file_path, raw_inputs |
| 249 | # for url, download and generate txt |
| 250 | result = urlparse(url) |
| 251 | if result.scheme is not None and len(result.scheme) > 0: |
| 252 | storage = HTTPStorage() |
| 253 | data = storage.read(url) |
| 254 | work_dir = tempfile.TemporaryDirectory().name |
| 255 | if not os.path.exists(work_dir): |
| 256 | os.makedirs(work_dir) |
| 257 | text_file_path = os.path.join(work_dir, os.path.basename(url)) |
| 258 | with open(text_file_path, 'wb') as fp: |
| 259 | fp.write(data) |
| 260 | return text_file_path, raw_inputs |
| 261 | |
| 262 | return text_file_path, raw_inputs |
| 263 | |
| 264 | |
| 265 | def generate_scp_for_sv(url: str, key: str = None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…