diff mbox series

[ovs-dev,v3,2/2] checkpatch.py: Load codespell dictionary.

Message ID 20231113130033.868689-3-roid@nvidia.com
State Changes Requested
Headers show
Series improve checkpatch spell checker | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Roi Dayan Nov. 13, 2023, 1 p.m. UTC
codespell dictionary contains a list of widely used words
which enchant alone could fail on. for an example:
refcount, pthread, enqueuing, etc.
Load that dictionary, if exists, into enchant spell checker.

Signed-off-by: Roi Dayan <roid@nvidia.com>
---
 utilities/checkpatch.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Aaron Conole Nov. 13, 2023, 5:08 p.m. UTC | #1
Roi Dayan <roid@nvidia.com> writes:

> codespell dictionary contains a list of widely used words
> which enchant alone could fail on. for an example:
> refcount, pthread, enqueuing, etc.
> Load that dictionary, if exists, into enchant spell checker.
>
> Signed-off-by: Roi Dayan <roid@nvidia.com>
> ---

Thanks for working on this.  Just some nits below and then I think it
would be ready for merge.

>  utilities/checkpatch.py | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
> index 2dd02ee6420c..2669eca11108 100755
> --- a/utilities/checkpatch.py
> +++ b/utilities/checkpatch.py
> @@ -39,6 +39,16 @@ spell_check_dict = None
>  def open_spell_check_dict():
>      import enchant
>  
> +    try:
> +        import codespell_lib
> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
> +        if not os.path.exists(codespell_file):
> +            codespell_file = ''
> +    except:
> +        codespell_file = ''
> +
> +

Looks like there's a flake8 flag here for whitespace.

Waiting for Eelco / others to chime in before I take it.

>      try:
>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>  
>          global spell_check_dict
> +
>          spell_check_dict = enchant.Dict("en_US")
> +
> +        if codespell_file:
> +            with open(codespell_file) as f:
> +                for line in f.readlines():
> +                    words = line.strip().split('>')[1].strip(', ').split(',')
> +                    for word in words:
> +                        spell_check_dict.add_to_session(word)
> +

I think the split(',') should also be: split(', ').  I noticed some of
the words added have a speace (such as):
 ' use'

>          for kw in extra_keywords:
>              spell_check_dict.add_to_session(kw)
Roi Dayan Nov. 14, 2023, 7:49 a.m. UTC | #2
On 13/11/2023 19:08, Aaron Conole wrote:
> Roi Dayan <roid@nvidia.com> writes:
> 
>> codespell dictionary contains a list of widely used words
>> which enchant alone could fail on. for an example:
>> refcount, pthread, enqueuing, etc.
>> Load that dictionary, if exists, into enchant spell checker.
>>
>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>> ---
> 
> Thanks for working on this.  Just some nits below and then I think it
> would be ready for merge.
> 
>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>> index 2dd02ee6420c..2669eca11108 100755
>> --- a/utilities/checkpatch.py
>> +++ b/utilities/checkpatch.py
>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>  def open_spell_check_dict():
>>      import enchant
>>  
>> +    try:
>> +        import codespell_lib
>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>> +        if not os.path.exists(codespell_file):
>> +            codespell_file = ''
>> +    except:
>> +        codespell_file = ''
>> +
>> +
> 
> Looks like there's a flake8 flag here for whitespace.
> 
> Waiting for Eelco / others to chime in before I take it.

right. I have 2 space lines by mistake. need to remove one space line.

> 
>>      try:
>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>  
>>          global spell_check_dict
>> +
>>          spell_check_dict = enchant.Dict("en_US")
>> +
>> +        if codespell_file:
>> +            with open(codespell_file) as f:
>> +                for line in f.readlines():
>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>> +                    for word in words:
>> +                        spell_check_dict.add_to_session(word)
>> +
> 
> I think the split(',') should also be: split(', ').  I noticed some of
> the words added have a speace (such as):
>  ' use'

you are right. with the tempfile I did word.strip() which is not here.
I missed the space on those words when checking.

> 
>>          for kw in extra_keywords:
>>              spell_check_dict.add_to_session(kw)
>
Eelco Chaudron Nov. 14, 2023, 9:29 a.m. UTC | #3
On 14 Nov 2023, at 8:49, Roi Dayan wrote:

> On 13/11/2023 19:08, Aaron Conole wrote:
>> Roi Dayan <roid@nvidia.com> writes:
>>
>>> codespell dictionary contains a list of widely used words
>>> which enchant alone could fail on. for an example:
>>> refcount, pthread, enqueuing, etc.
>>> Load that dictionary, if exists, into enchant spell checker.
>>>
>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>> ---
>>
>> Thanks for working on this.  Just some nits below and then I think it
>> would be ready for merge.
>>
>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>  1 file changed, 19 insertions(+)
>>>
>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>> index 2dd02ee6420c..2669eca11108 100755
>>> --- a/utilities/checkpatch.py
>>> +++ b/utilities/checkpatch.py
>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>  def open_spell_check_dict():
>>>      import enchant
>>>
>>> +    try:
>>> +        import codespell_lib
>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>> +        if not os.path.exists(codespell_file):
>>> +            codespell_file = ''
>>> +    except:
>>> +        codespell_file = ''
>>> +
>>> +
>>
>> Looks like there's a flake8 flag here for whitespace.
>>
>> Waiting for Eelco / others to chime in before I take it.
>
> right. I have 2 space lines by mistake. need to remove one space line.
>
>>
>>>      try:
>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>
>>>          global spell_check_dict
>>> +
>>>          spell_check_dict = enchant.Dict("en_US")
>>> +
>>> +        if codespell_file:
>>> +            with open(codespell_file) as f:
>>> +                for line in f.readlines():
>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>> +                    for word in words:
>>> +                        spell_check_dict.add_to_session(word)
>>> +
>>
>> I think the split(',') should also be: split(', ').  I noticed some of
>> the words added have a speace (such as):
>>  ' use'
>
> you are right. with the tempfile I did word.strip() which is not here.
> I missed the space on those words when checking.

I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:

+                    for word in words:
+                        spell_check_dict.add_to_session(word.strip())


With the above changes assuming Aaron would apply the patch.

Acked-by: Eelco Chaudron <echaudro@redhat.com>


>>
>>>          for kw in extra_keywords:
>>>              spell_check_dict.add_to_session(kw)
>>
Aaron Conole Nov. 15, 2023, 2:33 a.m. UTC | #4
Eelco Chaudron <echaudro@redhat.com> writes:

> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>
>> On 13/11/2023 19:08, Aaron Conole wrote:
>>> Roi Dayan <roid@nvidia.com> writes:
>>>
>>>> codespell dictionary contains a list of widely used words
>>>> which enchant alone could fail on. for an example:
>>>> refcount, pthread, enqueuing, etc.
>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>
>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>> ---
>>>
>>> Thanks for working on this.  Just some nits below and then I think it
>>> would be ready for merge.
>>>
>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>  1 file changed, 19 insertions(+)
>>>>
>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>> index 2dd02ee6420c..2669eca11108 100755
>>>> --- a/utilities/checkpatch.py
>>>> +++ b/utilities/checkpatch.py
>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>  def open_spell_check_dict():
>>>>      import enchant
>>>>
>>>> +    try:
>>>> +        import codespell_lib
>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>> +        if not os.path.exists(codespell_file):
>>>> +            codespell_file = ''
>>>> +    except:
>>>> +        codespell_file = ''
>>>> +
>>>> +
>>>
>>> Looks like there's a flake8 flag here for whitespace.
>>>
>>> Waiting for Eelco / others to chime in before I take it.
>>
>> right. I have 2 space lines by mistake. need to remove one space line.
>>
>>>
>>>>      try:
>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>
>>>>          global spell_check_dict
>>>> +
>>>>          spell_check_dict = enchant.Dict("en_US")
>>>> +
>>>> +        if codespell_file:
>>>> +            with open(codespell_file) as f:
>>>> +                for line in f.readlines():
>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>> +                    for word in words:
>>>> +                        spell_check_dict.add_to_session(word)
>>>> +
>>>
>>> I think the split(',') should also be: split(', ').  I noticed some of
>>> the words added have a speace (such as):
>>>  ' use'
>>
>> you are right. with the tempfile I did word.strip() which is not here.
>> I missed the space on those words when checking.
>
> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>
> +                    for word in words:
> +                        spell_check_dict.add_to_session(word.strip())
>
>
> With the above changes assuming Aaron would apply the patch.
>
> Acked-by: Eelco Chaudron <echaudro@redhat.com>

Sounds good to me.  I will apply the correct version.

>
>>>
>>>>          for kw in extra_keywords:
>>>>              spell_check_dict.add_to_session(kw)
>>>
Eelco Chaudron Dec. 14, 2023, 10:17 a.m. UTC | #5
On 15 Nov 2023, at 3:33, Aaron Conole wrote:

> Eelco Chaudron <echaudro@redhat.com> writes:
>
>> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>>
>>> On 13/11/2023 19:08, Aaron Conole wrote:
>>>> Roi Dayan <roid@nvidia.com> writes:
>>>>
>>>>> codespell dictionary contains a list of widely used words
>>>>> which enchant alone could fail on. for an example:
>>>>> refcount, pthread, enqueuing, etc.
>>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>>
>>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>>> ---
>>>>
>>>> Thanks for working on this.  Just some nits below and then I think it
>>>> would be ready for merge.
>>>>
>>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>>  1 file changed, 19 insertions(+)
>>>>>
>>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>>> index 2dd02ee6420c..2669eca11108 100755
>>>>> --- a/utilities/checkpatch.py
>>>>> +++ b/utilities/checkpatch.py
>>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>>  def open_spell_check_dict():
>>>>>      import enchant
>>>>>
>>>>> +    try:
>>>>> +        import codespell_lib
>>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>>> +        if not os.path.exists(codespell_file):
>>>>> +            codespell_file = ''
>>>>> +    except:
>>>>> +        codespell_file = ''
>>>>> +
>>>>> +
>>>>
>>>> Looks like there's a flake8 flag here for whitespace.
>>>>
>>>> Waiting for Eelco / others to chime in before I take it.
>>>
>>> right. I have 2 space lines by mistake. need to remove one space line.
>>>
>>>>
>>>>>      try:
>>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>>
>>>>>          global spell_check_dict
>>>>> +
>>>>>          spell_check_dict = enchant.Dict("en_US")
>>>>> +
>>>>> +        if codespell_file:
>>>>> +            with open(codespell_file) as f:
>>>>> +                for line in f.readlines():
>>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>>> +                    for word in words:
>>>>> +                        spell_check_dict.add_to_session(word)
>>>>> +
>>>>
>>>> I think the split(',') should also be: split(', ').  I noticed some of
>>>> the words added have a speace (such as):
>>>>  ' use'
>>>
>>> you are right. with the tempfile I did word.strip() which is not here.
>>> I missed the space on those words when checking.
>>
>> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>>
>> +                    for word in words:
>> +                        spell_check_dict.add_to_session(word.strip())
>>
>>
>> With the above changes assuming Aaron would apply the patch.
>>
>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>
> Sounds good to me.  I will apply the correct version.

Hi Aaron, just a reminder as this might have slipped your mind ;)

>>
>>>>
>>>>>          for kw in extra_keywords:
>>>>>              spell_check_dict.add_to_session(kw)
>>>>
Aaron Conole Dec. 14, 2023, 1:25 p.m. UTC | #6
Eelco Chaudron <echaudro@redhat.com> writes:

> On 15 Nov 2023, at 3:33, Aaron Conole wrote:
>
>> Eelco Chaudron <echaudro@redhat.com> writes:
>>
>>> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>>>
>>>> On 13/11/2023 19:08, Aaron Conole wrote:
>>>>> Roi Dayan <roid@nvidia.com> writes:
>>>>>
>>>>>> codespell dictionary contains a list of widely used words
>>>>>> which enchant alone could fail on. for an example:
>>>>>> refcount, pthread, enqueuing, etc.
>>>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>>>
>>>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>>>> ---
>>>>>
>>>>> Thanks for working on this.  Just some nits below and then I think it
>>>>> would be ready for merge.
>>>>>
>>>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>>>  1 file changed, 19 insertions(+)
>>>>>>
>>>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>>>> index 2dd02ee6420c..2669eca11108 100755
>>>>>> --- a/utilities/checkpatch.py
>>>>>> +++ b/utilities/checkpatch.py
>>>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>>>  def open_spell_check_dict():
>>>>>>      import enchant
>>>>>>
>>>>>> +    try:
>>>>>> +        import codespell_lib
>>>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>>>> +        if not os.path.exists(codespell_file):
>>>>>> +            codespell_file = ''
>>>>>> +    except:
>>>>>> +        codespell_file = ''
>>>>>> +
>>>>>> +
>>>>>
>>>>> Looks like there's a flake8 flag here for whitespace.
>>>>>
>>>>> Waiting for Eelco / others to chime in before I take it.
>>>>
>>>> right. I have 2 space lines by mistake. need to remove one space line.
>>>>
>>>>>
>>>>>>      try:
>>>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>>>
>>>>>>          global spell_check_dict
>>>>>> +
>>>>>>          spell_check_dict = enchant.Dict("en_US")
>>>>>> +
>>>>>> +        if codespell_file:
>>>>>> +            with open(codespell_file) as f:
>>>>>> +                for line in f.readlines():
>>>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>>>> +                    for word in words:
>>>>>> +                        spell_check_dict.add_to_session(word)
>>>>>> +
>>>>>
>>>>> I think the split(',') should also be: split(', ').  I noticed some of
>>>>> the words added have a speace (such as):
>>>>>  ' use'
>>>>
>>>> you are right. with the tempfile I did word.strip() which is not here.
>>>> I missed the space on those words when checking.
>>>
>>> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>>>
>>> +                    for word in words:
>>> +                        spell_check_dict.add_to_session(word.strip())
>>>
>>>
>>> With the above changes assuming Aaron would apply the patch.
>>>
>>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>>
>> Sounds good to me.  I will apply the correct version.
>
> Hi Aaron, just a reminder as this might have slipped your mind ;)

Sorry - I assumed that there would be a new version posted.  I can apply
with your change and the nits above corrected.  Is that okay Roi?

>>>
>>>>>
>>>>>>          for kw in extra_keywords:
>>>>>>              spell_check_dict.add_to_session(kw)
>>>>>
Roi Dayan Dec. 18, 2023, 7:45 a.m. UTC | #7
On 14/12/2023 15:25, Aaron Conole wrote:
> Eelco Chaudron <echaudro@redhat.com> writes:
> 
>> On 15 Nov 2023, at 3:33, Aaron Conole wrote:
>>
>>> Eelco Chaudron <echaudro@redhat.com> writes:
>>>
>>>> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>>>>
>>>>> On 13/11/2023 19:08, Aaron Conole wrote:
>>>>>> Roi Dayan <roid@nvidia.com> writes:
>>>>>>
>>>>>>> codespell dictionary contains a list of widely used words
>>>>>>> which enchant alone could fail on. for an example:
>>>>>>> refcount, pthread, enqueuing, etc.
>>>>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>>>>
>>>>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>>>>> ---
>>>>>>
>>>>>> Thanks for working on this.  Just some nits below and then I think it
>>>>>> would be ready for merge.
>>>>>>
>>>>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>>>>  1 file changed, 19 insertions(+)
>>>>>>>
>>>>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>>>>> index 2dd02ee6420c..2669eca11108 100755
>>>>>>> --- a/utilities/checkpatch.py
>>>>>>> +++ b/utilities/checkpatch.py
>>>>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>>>>  def open_spell_check_dict():
>>>>>>>      import enchant
>>>>>>>
>>>>>>> +    try:
>>>>>>> +        import codespell_lib
>>>>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>>>>> +        if not os.path.exists(codespell_file):
>>>>>>> +            codespell_file = ''
>>>>>>> +    except:
>>>>>>> +        codespell_file = ''
>>>>>>> +
>>>>>>> +
>>>>>>
>>>>>> Looks like there's a flake8 flag here for whitespace.
>>>>>>
>>>>>> Waiting for Eelco / others to chime in before I take it.
>>>>>
>>>>> right. I have 2 space lines by mistake. need to remove one space line.
>>>>>
>>>>>>
>>>>>>>      try:
>>>>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>>>>
>>>>>>>          global spell_check_dict
>>>>>>> +
>>>>>>>          spell_check_dict = enchant.Dict("en_US")
>>>>>>> +
>>>>>>> +        if codespell_file:
>>>>>>> +            with open(codespell_file) as f:
>>>>>>> +                for line in f.readlines():
>>>>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>>>>> +                    for word in words:
>>>>>>> +                        spell_check_dict.add_to_session(word)
>>>>>>> +
>>>>>>
>>>>>> I think the split(',') should also be: split(', ').  I noticed some of
>>>>>> the words added have a speace (such as):
>>>>>>  ' use'
>>>>>
>>>>> you are right. with the tempfile I did word.strip() which is not here.
>>>>> I missed the space on those words when checking.
>>>>
>>>> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>>>>
>>>> +                    for word in words:
>>>> +                        spell_check_dict.add_to_session(word.strip())
>>>>
>>>>
>>>> With the above changes assuming Aaron would apply the patch.
>>>>
>>>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>>>
>>> Sounds good to me.  I will apply the correct version.
>>
>> Hi Aaron, just a reminder as this might have slipped your mind ;)
> 
> Sorry - I assumed that there would be a new version posted.  I can apply
> with your change and the nits above corrected.  Is that okay Roi?
> 

hi, yes of course. thanks.

>>>>
>>>>>>
>>>>>>>          for kw in extra_keywords:
>>>>>>>              spell_check_dict.add_to_session(kw)
>>>>>>
>
Roi Dayan Jan. 9, 2024, 8:50 a.m. UTC | #8
On 18/12/2023 9:45, Roi Dayan wrote:
> 
> 
> On 14/12/2023 15:25, Aaron Conole wrote:
>> Eelco Chaudron <echaudro@redhat.com> writes:
>>
>>> On 15 Nov 2023, at 3:33, Aaron Conole wrote:
>>>
>>>> Eelco Chaudron <echaudro@redhat.com> writes:
>>>>
>>>>> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>>>>>
>>>>>> On 13/11/2023 19:08, Aaron Conole wrote:
>>>>>>> Roi Dayan <roid@nvidia.com> writes:
>>>>>>>
>>>>>>>> codespell dictionary contains a list of widely used words
>>>>>>>> which enchant alone could fail on. for an example:
>>>>>>>> refcount, pthread, enqueuing, etc.
>>>>>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>>>>>
>>>>>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>>>>>> ---
>>>>>>>
>>>>>>> Thanks for working on this.  Just some nits below and then I think it
>>>>>>> would be ready for merge.
>>>>>>>
>>>>>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>>>>>  1 file changed, 19 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>>>>>> index 2dd02ee6420c..2669eca11108 100755
>>>>>>>> --- a/utilities/checkpatch.py
>>>>>>>> +++ b/utilities/checkpatch.py
>>>>>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>>>>>  def open_spell_check_dict():
>>>>>>>>      import enchant
>>>>>>>>
>>>>>>>> +    try:
>>>>>>>> +        import codespell_lib
>>>>>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>>>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>>>>>> +        if not os.path.exists(codespell_file):
>>>>>>>> +            codespell_file = ''
>>>>>>>> +    except:
>>>>>>>> +        codespell_file = ''
>>>>>>>> +
>>>>>>>> +
>>>>>>>
>>>>>>> Looks like there's a flake8 flag here for whitespace.
>>>>>>>
>>>>>>> Waiting for Eelco / others to chime in before I take it.
>>>>>>
>>>>>> right. I have 2 space lines by mistake. need to remove one space line.
>>>>>>
>>>>>>>
>>>>>>>>      try:
>>>>>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>>>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>>>>>
>>>>>>>>          global spell_check_dict
>>>>>>>> +
>>>>>>>>          spell_check_dict = enchant.Dict("en_US")
>>>>>>>> +
>>>>>>>> +        if codespell_file:
>>>>>>>> +            with open(codespell_file) as f:
>>>>>>>> +                for line in f.readlines():
>>>>>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>>>>>> +                    for word in words:
>>>>>>>> +                        spell_check_dict.add_to_session(word)
>>>>>>>> +
>>>>>>>
>>>>>>> I think the split(',') should also be: split(', ').  I noticed some of
>>>>>>> the words added have a speace (such as):
>>>>>>>  ' use'
>>>>>>
>>>>>> you are right. with the tempfile I did word.strip() which is not here.
>>>>>> I missed the space on those words when checking.
>>>>>
>>>>> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>>>>>
>>>>> +                    for word in words:
>>>>> +                        spell_check_dict.add_to_session(word.strip())
>>>>>
>>>>>
>>>>> With the above changes assuming Aaron would apply the patch.
>>>>>
>>>>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>>>>
>>>> Sounds good to me.  I will apply the correct version.
>>>
>>> Hi Aaron, just a reminder as this might have slipped your mind ;)
>>
>> Sorry - I assumed that there would be a new version posted.  I can apply
>> with your change and the nits above corrected.  Is that okay Roi?
>>
> 
> hi, yes of course. thanks.
> 

Hi Aaron, Are you taking this?
thanks


>>>>>
>>>>>>>
>>>>>>>>          for kw in extra_keywords:
>>>>>>>>              spell_check_dict.add_to_session(kw)
>>>>>>>
>>
Aaron Conole Jan. 9, 2024, 2:20 p.m. UTC | #9
Roi Dayan <roid@nvidia.com> writes:

> On 18/12/2023 9:45, Roi Dayan wrote:
>> 
>> 
>> On 14/12/2023 15:25, Aaron Conole wrote:
>>> Eelco Chaudron <echaudro@redhat.com> writes:
>>>
>>>> On 15 Nov 2023, at 3:33, Aaron Conole wrote:
>>>>
>>>>> Eelco Chaudron <echaudro@redhat.com> writes:
>>>>>
>>>>>> On 14 Nov 2023, at 8:49, Roi Dayan wrote:
>>>>>>
>>>>>>> On 13/11/2023 19:08, Aaron Conole wrote:
>>>>>>>> Roi Dayan <roid@nvidia.com> writes:
>>>>>>>>
>>>>>>>>> codespell dictionary contains a list of widely used words
>>>>>>>>> which enchant alone could fail on. for an example:
>>>>>>>>> refcount, pthread, enqueuing, etc.
>>>>>>>>> Load that dictionary, if exists, into enchant spell checker.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Roi Dayan <roid@nvidia.com>
>>>>>>>>> ---
>>>>>>>>
>>>>>>>> Thanks for working on this.  Just some nits below and then I think it
>>>>>>>> would be ready for merge.
>>>>>>>>
>>>>>>>>>  utilities/checkpatch.py | 19 +++++++++++++++++++
>>>>>>>>>  1 file changed, 19 insertions(+)
>>>>>>>>>
>>>>>>>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>>>>>>>> index 2dd02ee6420c..2669eca11108 100755
>>>>>>>>> --- a/utilities/checkpatch.py
>>>>>>>>> +++ b/utilities/checkpatch.py
>>>>>>>>> @@ -39,6 +39,16 @@ spell_check_dict = None
>>>>>>>>>  def open_spell_check_dict():
>>>>>>>>>      import enchant
>>>>>>>>>
>>>>>>>>> +    try:
>>>>>>>>> +        import codespell_lib
>>>>>>>>> +        codespell_dir = os.path.dirname(codespell_lib.__file__)
>>>>>>>>> +        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
>>>>>>>>> +        if not os.path.exists(codespell_file):
>>>>>>>>> +            codespell_file = ''
>>>>>>>>> +    except:
>>>>>>>>> +        codespell_file = ''
>>>>>>>>> +
>>>>>>>>> +
>>>>>>>>
>>>>>>>> Looks like there's a flake8 flag here for whitespace.
>>>>>>>>
>>>>>>>> Waiting for Eelco / others to chime in before I take it.
>>>>>>>
>>>>>>> right. I have 2 space lines by mistake. need to remove one space line.
>>>>>>>
>>>>>>>>
>>>>>>>>>      try:
>>>>>>>>>          extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
>>>>>>>>>                            'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
>>>>>>>>> @@ -91,7 +101,16 @@ def open_spell_check_dict():
>>>>>>>>>                            'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
>>>>>>>>>
>>>>>>>>>          global spell_check_dict
>>>>>>>>> +
>>>>>>>>>          spell_check_dict = enchant.Dict("en_US")
>>>>>>>>> +
>>>>>>>>> +        if codespell_file:
>>>>>>>>> +            with open(codespell_file) as f:
>>>>>>>>> +                for line in f.readlines():
>>>>>>>>> +                    words = line.strip().split('>')[1].strip(', ').split(',')
>>>>>>>>> +                    for word in words:
>>>>>>>>> +                        spell_check_dict.add_to_session(word)
>>>>>>>>> +
>>>>>>>>
>>>>>>>> I think the split(',') should also be: split(', ').  I noticed some of
>>>>>>>> the words added have a speace (such as):
>>>>>>>>  ' use'
>>>>>>>
>>>>>>> you are right. with the tempfile I did word.strip() which is not here.
>>>>>>> I missed the space on those words when checking.
>>>>>>
>>>>>> I guess keeping the original single ’,’ split, and adding word.strip() would be better, i.e.:
>>>>>>
>>>>>> +                    for word in words:
>>>>>> +                        spell_check_dict.add_to_session(word.strip())
>>>>>>
>>>>>>
>>>>>> With the above changes assuming Aaron would apply the patch.
>>>>>>
>>>>>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>>>>>
>>>>> Sounds good to me.  I will apply the correct version.
>>>>
>>>> Hi Aaron, just a reminder as this might have slipped your mind ;)
>>>
>>> Sorry - I assumed that there would be a new version posted.  I can apply
>>> with your change and the nits above corrected.  Is that okay Roi?
>>>
>> 
>> hi, yes of course. thanks.
>> 
>
> Hi Aaron, Are you taking this?
> thanks

Yes - applied.  Thanks all.

>
>>>>>>
>>>>>>>>
>>>>>>>>>          for kw in extra_keywords:
>>>>>>>>>              spell_check_dict.add_to_session(kw)
>>>>>>>>
>>>
diff mbox series

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 2dd02ee6420c..2669eca11108 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -39,6 +39,16 @@  spell_check_dict = None
 def open_spell_check_dict():
     import enchant
 
+    try:
+        import codespell_lib
+        codespell_dir = os.path.dirname(codespell_lib.__file__)
+        codespell_file = os.path.join(codespell_dir, 'data', 'dictionary.txt')
+        if not os.path.exists(codespell_file):
+            codespell_file = ''
+    except:
+        codespell_file = ''
+
+
     try:
         extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
                           'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
@@ -91,7 +101,16 @@  def open_spell_check_dict():
                           'syscall', 'lacp', 'ipf', 'skb', 'valgrind']
 
         global spell_check_dict
+
         spell_check_dict = enchant.Dict("en_US")
+
+        if codespell_file:
+            with open(codespell_file) as f:
+                for line in f.readlines():
+                    words = line.strip().split('>')[1].strip(', ').split(',')
+                    for word in words:
+                        spell_check_dict.add_to_session(word)
+
         for kw in extra_keywords:
             spell_check_dict.add_to_session(kw)