Skip to content

Commit 1f614be

Browse files
committed
Fixed #113 and #153 by using the expanduser from os.path
1 parent 946ab0c commit 1f614be

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

about_code_tool/genabout.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from collections import namedtuple
3838
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
4040

4141
import about
4242

@@ -702,11 +702,17 @@ def main(parser, options, args):
702702
print('Invalid action: should be 0, 1, 2 or 3')
703703
sys.exit(errno.EINVAL)
704704

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):
706709
print("The project path does not exist.")
707710
sys.exit(errno.EINVAL)
708711

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):
710716
print("The license text path does not exist.")
711717
sys.exit(errno.EINVAL)
712718

@@ -793,32 +799,29 @@ def main(parser, options, args):
793799
ignored_fields_list)
794800

795801
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):
798803
print("The '--copy_files' <project_path> must be a directory.")
799804
print("'--copy_files' is skipped.")
800805
else:
801-
project_parent_dir = dirname(copy_files_location)
802806
licenses_in_project = True
803807
license_list = gen.verify_files_existence(input_list,
804-
project_parent_dir,
808+
copy_files_path,
805809
licenses_in_project)
806810
if not license_list:
807811
print("None of the file is found. '--copy_files' is ignored.")
808812
else:
809813
gen.copy_files(output_path, license_list)
810814

811815
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):
814818
print("The '--license_text_location' <license_path> "
815819
"must be a directory.")
816820
print("'--license_text_location' is skipped.")
817821
else:
818-
license_dir = dirname(license_text_location)
819822
licenses_in_project = False
820823
license_list = gen.verify_files_existence(input_list,
821-
license_dir,
824+
license_text_path,
822825
licenses_in_project)
823826
if not license_list:
824827
print("None of the file is found. '--copy_files' is ignored.")

0 commit comments

Comments
 (0)