Skip to content

Commit 5716ee4

Browse files
committed
Primitive support for URLs
1 parent f133a21 commit 5716ee4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343

44-
* furthermore , you can now sub index strings, arithmetical operations and more! Regarding strings, you can now get words of the sentenceseparated by space or by full stop, but you can also pick up parts of the snake or camel case words as well as individual letters!
44+
* furthermore , you can now sub index strings, arithmetical operations and more! Regarding strings, you can now get words of the sentenceseparated by space or by full stop, but you can also pick up parts of the snake or camel case words individual letters , as well as parts of a URL( little more work is needed for the latter)!
4545

4646
* the abstract_vertical and big_roi modules have been modified so as to offer alternatives when there are multiple logical lines in the same physical line.
4747

library/info.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ast
2-
from itertools import chain
32
import re
3+
from itertools import chain
4+
from urllib.parse import urlparse
45

56
from PythonVoiceCodingPlugin.library import build_tree,get_source_region,nearest_node_from_offset,make_flat,previous_token,next_token
67
from PythonVoiceCodingPlugin.library.traverse import match_node, find_all_nodes, match_parent,search_upwards_log
@@ -282,9 +283,12 @@ def get_subparts_of_binary_operation(root):
282283
return left + right
283284

284285

285-
def split_string(s):
286+
def split_string(s,even_letters = True):
286287
s = s.strip()
287-
first_attempt = [x for x in re.split("[., ]",s) if not x.isspace()]
288+
y = urlparse(s)
289+
if not (y.scheme=="" and y.netloc==""):
290+
return make_flat( [split_string(x,False) for x in y ])
291+
first_attempt = [x for x in re.split("[., :/]",s) if not x.isspace()]
288292
if len(first_attempt) > 1:
289293
return first_attempt
290294
second_attempt = [x for x in re.split("[_]",s) if not x.isspace()]
@@ -294,7 +298,7 @@ def split_string(s):
294298
if len(third_attempt) > 1:
295299
return third_attempt
296300

297-
return list(s)
301+
return list(s) if even_letters else [s]
298302

299303

300304

0 commit comments

Comments
 (0)