[libcamera-devel,v2] utils: ipc: extract-docs: Extract the SPDX header
diff mbox series

Message ID 20210528102956.2750155-1-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,v2] utils: ipc: extract-docs: Extract the SPDX header
Related show

Commit Message

Paul Elder May 28, 2021, 10:29 a.m. UTC
Take the SPDX header from the mojom file. Error out if it doesn't

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v2:
- Error out if SPDX header is unavailable
- add newline at end of default SPDX string
---
 utils/ipc/extract-docs.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart May 28, 2021, 10:34 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, May 28, 2021 at 07:29:56PM +0900, Paul Elder wrote:
> Take the SPDX header from the mojom file. Error out if it doesn't

If it doesn't what ? :-)

> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
> Changes in v2:
> - Error out if SPDX header is unavailable
> - add newline at end of default SPDX string
> ---
>  utils/ipc/extract-docs.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> index 56566ce0..1ff9a775 100755
> --- a/utils/ipc/extract-docs.py
> +++ b/utils/ipc/extract-docs.py
> @@ -12,6 +12,7 @@ import sys
>  
>  regex_block_start = re.compile('^\/\*\*$')
>  regex_block_end = re.compile('^ \*\/$')
> +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
>  
>  
>  def main(argv):
> @@ -28,8 +29,13 @@ def main(argv):
>  
>      lines = open(args.input, 'r').readlines()
>      pipeline = args.input.split('/')[-1].replace('.mojom', '')
> -    data = f'''\
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +
> +    if regex_spdx.match(lines[0]):
> +        data = lines[0]
> +    else:
> +        raise Exception(f'Missing SPDX license header in {args.input}')

I would write

    if not regex_spdx.match(lines[0]):
        raise Exception(f'Missing SPDX license header in {args.input}')

    data = lines[0]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +
> +    data += f'''\
>  /*
>   * Copyright (C) 2021, Google Inc.
>   *
Umang Jain May 28, 2021, 2:05 p.m. UTC | #2
Hi Paul,

Thanks for the patch.

On 5/28/21 4:04 PM, Laurent Pinchart wrote:
> Hi Paul,
>
> Thank you for the patch.
>
> On Fri, May 28, 2021 at 07:29:56PM +0900, Paul Elder wrote:
>> Take the SPDX header from the mojom file. Error out if it doesn't
> If it doesn't what ? :-)
>
>> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
>> ---
>> Changes in v2:
>> - Error out if SPDX header is unavailable
>> - add newline at end of default SPDX string
>> ---
>>   utils/ipc/extract-docs.py | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
>> index 56566ce0..1ff9a775 100755
>> --- a/utils/ipc/extract-docs.py
>> +++ b/utils/ipc/extract-docs.py
>> @@ -12,6 +12,7 @@ import sys
>>   
>>   regex_block_start = re.compile('^\/\*\*$')
>>   regex_block_end = re.compile('^ \*\/$')
>> +regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
>>   
>>   
>>   def main(argv):
>> @@ -28,8 +29,13 @@ def main(argv):
>>   
>>       lines = open(args.input, 'r').readlines()
>>       pipeline = args.input.split('/')[-1].replace('.mojom', '')
>> -    data = f'''\
>> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
>> +
>> +    if regex_spdx.match(lines[0]):
>> +        data = lines[0]
>> +    else:
>> +        raise Exception(f'Missing SPDX license header in {args.input}')
> I would write
>
>      if not regex_spdx.match(lines[0]):
>          raise Exception(f'Missing SPDX license header in {args.input}')
>
>      data = lines[0]
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
With Laurent's suggestions in place (better readability of the code) :-)

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

>
>> +
>> +    data += f'''\
>>   /*
>>    * Copyright (C) 2021, Google Inc.
>>    *

Patch
diff mbox series

diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
index 56566ce0..1ff9a775 100755
--- a/utils/ipc/extract-docs.py
+++ b/utils/ipc/extract-docs.py
@@ -12,6 +12,7 @@  import sys
 
 regex_block_start = re.compile('^\/\*\*$')
 regex_block_end = re.compile('^ \*\/$')
+regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
 
 
 def main(argv):
@@ -28,8 +29,13 @@  def main(argv):
 
     lines = open(args.input, 'r').readlines()
     pipeline = args.input.split('/')[-1].replace('.mojom', '')
-    data = f'''\
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+    if regex_spdx.match(lines[0]):
+        data = lines[0]
+    else:
+        raise Exception(f'Missing SPDX license header in {args.input}')
+
+    data += f'''\
 /*
  * Copyright (C) 2021, Google Inc.
  *