|
36 | 36 |
|
37 | 37 | from collections import namedtuple |
38 | 38 | from os import makedirs |
39 | | -from os.path import exists, dirname, join, abspath, isdir, normpath, basename |
| 39 | +from os.path import exists, dirname, join, abspath, isdir, normpath, basename, expanduser |
40 | 40 |
|
41 | 41 | import about |
42 | 42 |
|
@@ -702,11 +702,17 @@ def main(parser, options, args): |
702 | 702 | print('Invalid action: should be 0, 1, 2 or 3') |
703 | 703 | sys.exit(errno.EINVAL) |
704 | 704 |
|
705 | | - if copy_files_path and not _exists(copy_files_path): |
| 705 | + if copy_files_path: |
| 706 | + # code to handle tidle character |
| 707 | + copy_files_path = os.path.abspath(expanduser(copy_files_path)) |
| 708 | + if not _exists(copy_files_path): |
706 | 709 | print("The project path does not exist.") |
707 | 710 | sys.exit(errno.EINVAL) |
708 | 711 |
|
709 | | - if license_text_path and not _exists(license_text_path): |
| 712 | + if license_text_path: |
| 713 | + # code to handle tidle character |
| 714 | + license_text_path = os.path.abspath(expanduser(license_text_path)) |
| 715 | + if not _exists(license_text_path): |
710 | 716 | print("The license text path does not exist.") |
711 | 717 | sys.exit(errno.EINVAL) |
712 | 718 |
|
@@ -793,32 +799,29 @@ def main(parser, options, args): |
793 | 799 | ignored_fields_list) |
794 | 800 |
|
795 | 801 | if copy_files_path: |
796 | | - copy_files_location = os.path.abspath(copy_files_path) |
797 | | - if not isdir(copy_files_location): |
| 802 | + if not isdir(copy_files_path): |
798 | 803 | print("The '--copy_files' <project_path> must be a directory.") |
799 | 804 | print("'--copy_files' is skipped.") |
800 | 805 | else: |
801 | | - project_parent_dir = dirname(copy_files_location) |
802 | 806 | licenses_in_project = True |
803 | 807 | license_list = gen.verify_files_existence(input_list, |
804 | | - project_parent_dir, |
| 808 | + copy_files_path, |
805 | 809 | licenses_in_project) |
806 | 810 | if not license_list: |
807 | 811 | print("None of the file is found. '--copy_files' is ignored.") |
808 | 812 | else: |
809 | 813 | gen.copy_files(output_path, license_list) |
810 | 814 |
|
811 | 815 | if license_text_path: |
812 | | - license_text_location = os.path.abspath(license_text_path) |
813 | | - if not isdir(license_text_location): |
| 816 | + print(normpath(license_text_path)) |
| 817 | + if not isdir(license_text_path): |
814 | 818 | print("The '--license_text_location' <license_path> " |
815 | 819 | "must be a directory.") |
816 | 820 | print("'--license_text_location' is skipped.") |
817 | 821 | else: |
818 | | - license_dir = dirname(license_text_location) |
819 | 822 | licenses_in_project = False |
820 | 823 | license_list = gen.verify_files_existence(input_list, |
821 | | - license_dir, |
| 824 | + license_text_path, |
822 | 825 | licenses_in_project) |
823 | 826 | if not license_list: |
824 | 827 | print("None of the file is found. '--copy_files' is ignored.") |
|
0 commit comments