Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d9fbbb

Browse files
Merge pull request #37 from mpourmpoulis/develop-0.1.0
Develop 0.1.3 first attempt
2 parents e105f65 + 8389c8b commit 7d9fbbb

29 files changed

+267
-261
lines changed

‎.pylintrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.app
77

88
[MESSAGES CONTROL]
99
disable=all
10+
11+
12+
1013
enable=E
14+

‎Main.sublime-menu‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,49 +35,49 @@
3535
"caption": "Argument Queries",
3636
"command": "open_url",
3737
"args":{
38-
"url": "http://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SelectArgument.md"
38+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/SelectArgument/"
3939
}
4040
},
4141
{
4242
"caption": "Big Roi Queries",
4343
"command": "open_url",
4444
"args":{
45-
"url":"https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SelectBigROI.md"
45+
"url":"https://pythonvoicecodingplugin.readthedocs.io/en/latest/SelectBigROI/"
4646
}
4747
},
4848
{
4949
"caption": "General Documentation",
5050
"command": "open_url",
5151
"args":{
52-
"url":"https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/README.md"
52+
"url":"https://pythonvoicecodingplugin.readthedocs.io/en/latest/"
5353
}
5454
},
5555
{
5656
"caption": "Operations",
5757
"command": "open_url",
5858
"args":{
59-
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/Operations.md"
59+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/Operations/"
6060
}
6161
},
6262
{
6363
"caption": "Sub Indexing",
6464
"command": "open_url",
6565
"args":{
66-
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SubIndexing.md"
66+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/SubIndexing/"
6767
}
6868
},
6969
{
7070
"caption": "CollectionQueries",
7171
"command": "open_url",
7272
"args":{
73-
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/CollectionQueries.md"
73+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/CollectionQueries/"
7474
}
7575
},
7676
{
7777
"caption": "Unofficial",
7878
"command": "open_url",
7979
"args":{
80-
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/README.md#experiment-or-unofficial-and-so-on-features-you-need-to-enable-manually"
80+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/#experiment-or-unofficial-and-so-on-features-you-need-to-enable-manually"
8181
}
8282
}
8383

@@ -125,7 +125,7 @@
125125
"caption": "Grammar Installation Doc",
126126
"command": "open_url",
127127
"args":{
128-
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/bundles/README.md"
128+
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/Installation/"
129129
}
130130
},
131131
{

‎application/application.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ def __init__(self,vid):
3030
self.ui_controller = None
3131
self.vid = vid
3232

33+
@staticmethod
3334
def create_application_for_view(vid):
3435
if vid not in Application.active_applications:
3536
Application.active_applications[vid] = Application(vid)
3637

38+
@staticmethod
3739
def get_application(vid):
3840
Application.create_application_for_view(vid)
3941
return Application.active_applications[vid]
@@ -77,6 +79,7 @@ def respond_to_query(self,interface,query_description,secondary=False):
7779
except Exception as e:
7880
# check if there are exceptions with parsing
7981
if s.exceptions_raised:
82+
# traceback.print_tb(s.exceptions_raised)
8083
interface.clear_actions()
8184
interface.push_action(PopUpErrorAction(str(s.exceptions_raised)))
8285
return False

‎bundles/Caster/python_voice_coding_plugin_caster_v0-5-11.py‎

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

3838
#########################################################################################
3939

40-
GRAMMAR_VERSION = (0,1,2)
40+
GRAMMAR_VERSION = (0,1,3)
4141

4242
#########################################################################################
4343

‎bundles/Caster/python_voice_coding_plugin_caster_v0-6-11.py‎

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

3838
#########################################################################################
3939

40-
GRAMMAR_VERSION = (0,1,2)
40+
GRAMMAR_VERSION = (0,1,3)
4141

4242
#########################################################################################
4343

‎bundles/Caster/python_voice_coding_plugin_caster_v1-0-0.py‎

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

3838
#########################################################################################
3939

40-
GRAMMAR_VERSION = (0,1,2)
40+
GRAMMAR_VERSION = (0,1,3)
4141

4242
#########################################################################################
4343

‎interface/common/actions.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,11 @@ class PopUpErrorAction(InterfaceAction):
232232
"""docstring for DisplayErrorAction"""
233233
def __init__(self, text):
234234
self.text = text
235+
235236
def execute(self,view,settings, sublime,**kwargs):
236237
if not settings.get("show_error",False):
237238
return
238-
final_text = "<p></p><h>Something is off!</h>" + "<p>" + html.escape(self.text) + "</p>"
239+
final_text = "<p></p><h>Something is off!</h>" + "<p>" + html.escape(self.text,quote=False) + "</p>"
239240
def on_hide():
240241
view.show_popup(final_text,max_width=1024, max_height=10000, flags= sublime.HIDE_ON_MOUSE_MOVE_AWAY)
241242
view.show_popup(final_text,max_width=1024, max_height=10000,

‎library/LCA.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def visit(self, node):
3737
def get_depth(self, node):
3838
return self.sequence[self.visits[node][0]][0]
3939

40-
def __call__(self,first_node,second_node,include_depth = False):
40+
def __call__(self,first_node,second_node,only_depth = False,node_and_depth=True):
4141
try :
4242
x,y = self.visits[first_node]
4343
w,v = self.visits[second_node]
@@ -52,9 +52,12 @@ def __call__(self,first_node,second_node,include_depth = False):
5252
r = max(y,v)
5353

5454
ancestor = self.tree.query(l,r,"min")
55-
if include_depth:
55+
if node_and_depth:
56+
return ancestor
57+
elif only_depth:
5658
return ancestor[0]
57-
return ancestor[1]
59+
else:
60+
return ancestor[1]
5861

5962
def get_field_with_respect_to(self,node,parent_node):
6063
index = bisect.bisect_left(self.field_history[parent_node],(self.visits[node][0],))

‎library/info.py‎

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ def fake_attribute_from_tokens(root,tokens,**kwargs):
129129

130130
def is_store(root):
131131
return match_node(root,ast.Store) or (match_node(root,ast.Name) and match_node(root.ctx,ast.Store))
132+
132133
def single(root):
133-
return match_parent(node,(),ast.Attribute)
134+
return match_parent(root,(),ast.Attribute)
134135

135136
def name(root):
136137
return match_node(root,ast.Name)
@@ -207,8 +208,6 @@ def get_weak_header(root,atok):
207208
root.items if match_node(root,(ast.With)) else
208209
root.type if match_node(root,(ast.ExceptHandler)) else None
209210
)
210-
def get_body(root):
211-
return root.body if match_node(root,(ast.IfExp, ast.If ,ast.For,ast.While, ast.Try)) else None
212211

213212

214213

@@ -255,12 +254,12 @@ def get_return_value(root):
255254
# need to revisit
256255
def get_elements(root):
257256
return (
258-
root.elts if hasattr(root,elts) else None
257+
root.elts if hasattr(root,"elts") else None
259258
)
260259

261260
def get_context(root):
262261
return (
263-
root.ctx if hasattr(root,ctx) else None
262+
root.ctx if hasattr(root,"ctx") else None
264263
)
265264

266265
def get_key_value(root):
@@ -321,6 +320,17 @@ def get_container_check(root):
321320
def get_membership(root):
322321
return root if match_node(root,ast.Compare) and all([match_node(x,(ast.In,ast.NotIn)) for x in root.ops]) else None
323322

323+
324+
# Extracting Identity Left And Right
325+
def get_identity_check_left(root):
326+
return root.left if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None
327+
328+
def get_identity_check_right(root):
329+
return root.comparators[-1] if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None
330+
331+
def get_identity_check(root):
332+
return root if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None
333+
324334
# Extract Left Middle And Right from numerical comparisons
325335
def get_comparison_left_side(root):
326336
return root.left if match_node(root,ast.Compare) else None
@@ -667,28 +677,29 @@ def get_subparts_of_string(root,name_mode = False):
667677
start_position = 1
668678
if not check_fake(root):
669679
x = root.first_token.string
670-
# print("String:\n",x)
671680
y1 = x.find("'")
672681
y2 = x.find("\"")
673682
if y1>=0 and y2>=0:
674-
z = mean(y1,y2)
683+
z = min(y1,y2)
675684
elif y1>=0:
676685
z = y1
677686
elif y2>=0:
678687
z = y2
679688
else:
680689
raise Exception("problem with splitting a string , there is no beginning!")
690+
try :
691+
if x[z]==x[z+1]==x[z+2]:
692+
z = z + 2
693+
except :
694+
pass
681695
start_position += z
682696
start_position += root.first_token.startpos
683-
# print("Start Position:\n",start_position)
684-
# start_position = root.first_token.startpos + ( 1+(len(root.first_token.string) if root.first_token.type==tokenize.NAME else 0) if not name_mode else 0)
685697
original = root.s if not name_mode else root.id
686698
try :
687699
splitted = split_string(root.s if not name_mode else root.id,even_letters = False if name_mode else True)
688700
except :
689701
print(" exceptions were thrown")
690702
index = 0
691-
print("splitted ",splitted)
692703
for s in splitted:
693704
if not s:
694705
continue
@@ -881,12 +892,11 @@ def get_raw(root):
881892

882893
def correspond_to_index_in_call(root, index,field,field_index):
883894
x = get_argument_from_call(root,index)
884-
print("entering index taking \n",ast.dump(x))
885895
if not x:
886896
return False
887897
if x.parent_field=="value":
888898
x = x.parent
889-
print("inside checking for index ",(x.parent_field,x.parent_field_index),(field,field_index))
899+
# print("inside checking for index ",(x.parent_field,x.parent_field_index),(field,field_index))
890900
return (field, field_index)==(x.parent_field,x.parent_field_index) if x else False
891901

892902

@@ -1016,6 +1026,9 @@ def fix_alias(root,atok):
10161026
def fix_argument(root,atok,token = None):
10171027
if already_fixed(root):
10181028
return token
1029+
# the following check was introduced to work around issue #17
1030+
if not match_node(root.parent.parent,ast.FunctionDef):
1031+
return None
10191032
if token is None:
10201033
fix_definition(root.parent.parent,atok)
10211034
if not already_fixed(root):
@@ -1037,15 +1050,14 @@ def fix_argument(root,atok,token = None):
10371050
def fix_argument_list(root,atok):
10381051
if not match_node(root,ast.arguments):
10391052
return False
1040-
if already_fixed(root) or fix_definition(root.parent,atok):
1053+
if already_fixed(root) or match_node(root.parent,(ast.FunctionDef)) andfix_definition(root.parent,atok):
10411054
return True
10421055
return False
10431056

10441057

10451058
def fix_definition(root,atok):
10461059
if already_fixed(root):
10471060
return True
1048-
10491061
# there is a discrepancy between the 3.3 and 3.4 versions of the abstract syntax tree
10501062
# in 3.3 the variable arguments and the variable keyboard arguments are stored in a little bit differently
10511063
x = root.args
@@ -1116,12 +1128,13 @@ def fix_exception_handler(root,atok):
11161128
if not root.type or not root.name:
11171129
mark_fixed(root)
11181130
return True
1119-
print("Exception Handler:\n",[root.first_token,root.last_token])
1131+
11201132
token = root.type.last_token
11211133
token = atok.find_token(next_token(atok,token),tokenize.NAME, root.name)
11221134
f = root.type.first_token
11231135
f = atok.find_token(previous_token(atok,f),tokenize.NAME, "except",reverse = True)
1124-
fake_name_node = create_fake(root,ast.Name,real_tokens = token,id = token.string,ctx = ast.Load())
1136+
fake_name_node = create_fake(root,ast.Name,real_tokens = token,id = token.string,ctx = ast.Load(),
1137+
parent = root,parent_field = "name")
11251138
set_fake(root,"name",fake_name_node)
11261139
# root.first_token=root.type.first_token
11271140
# root.last_token = token

‎library/modification.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def add_modification_from(self,timestamp, origin, destination,original_code =
5858
return self.add_modification(origin, destination, original_code, destination_code,comment)
5959

6060
def add_modification_updated(self, origin, destination,original_code = None,destination_code = "", comment= None):
61-
return add_modification_from(self.current_time, origin, destination,original_code ,destination_code , comment)
61+
return self.add_modification_from(self.current_time, origin, destination,original_code ,destination_code , comment)
6262

6363

6464

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /