-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added useflags check thanks to appi 0.1
- Loading branch information
Showing
4 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ __author__ = "Antoine Pinsard" | |
__copyright__ = "Copyright (C) 2017 Antoine Pinsard" | ||
__credits__ = ["Antoine Pinsard"] | ||
__license__ = "GPL-2" | ||
__version__ = "1.1" | ||
__version__ = "1.2" | ||
__maintainer__ = "Antoine Pinsard" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -72,8 +72,9 @@ def usage(): | |
uinfo = ( | ||
"chuse [-f|--force] <atom> [[modifier]<flag> ...] [--because <reason>]\n" | ||
" Alter use flags. By default, if the given atom doesn't match any existing ebuild,\n" | ||
" an error will be raised. Use -f/--force option to disable this behavior. If no flag\n" | ||
" is specified, the current rules matching the underlying atom will be displayed.\n" | ||
" or if one of the given useflags doesn't seem to exist, an error will be raised.\n" | ||
" Use -f/--force option to disable this behavior. If no flag is specified, the\n" | ||
" current rules matching the underlying atom will be displayed.\n" | ||
"chuse <atom>\n" | ||
" Print current flags set and history.\n" | ||
"chuse (-h|--help)\n" | ||
|
@@ -98,7 +99,7 @@ def usage(): | |
|
||
|
||
def version_info(): | ||
webpage = "https://github.com/apinsard/chuse" | ||
webpage = "https://gitlab.com/apinsard/chuse" | ||
vinfo = ("Chuse version %(version)s, %(copyright)s\n" | ||
"Chuse comes with ABSOLUTELY NO WARRANTY\n" | ||
"This is free software, and you are welcome to redistribute it\n" | ||
|
@@ -203,7 +204,7 @@ def read_current_flags(atom): | |
break # Another matching line would be foolish | ||
except FileNotFoundError: | ||
pass # Then there is no flag for now | ||
except NotADirectory: | ||
except NotADirectoryError: | ||
raise PackageUseError() | ||
|
||
return useflags | ||
|
@@ -244,7 +245,7 @@ def write_changes(atom, flags, comment): | |
os.makedirs(os.path.dirname(filename)) | ||
except FileExistsError: | ||
pass # Then we don't need to create it | ||
except NotADirectory: | ||
except NotADirectoryError: | ||
raise PackageUseError() | ||
|
||
if not found_existing_atom: | ||
|
@@ -443,6 +444,16 @@ def main(): | |
if reason: | ||
comment += '\n' + reason | ||
|
||
if not force: | ||
unexisting_flags = set(new_flags.keys()).difference( | ||
atom.list_possible_useflags()) | ||
if unexisting_flags: | ||
error(( | ||
"No ebuild matched by the given atom accepts such use " | ||
"flags: {}. Make sure you did not make a typo, or use " | ||
"--force option to proceed anyway." | ||
).format(', '.join(unexisting_flags))) | ||
|
||
try: | ||
write_changes(atom, new_flags, comment) | ||
except PackageUseError as e: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,8 @@ this and if you can reset default in the future for instance). | |
|
||
=item B<-f --force> | ||
|
||
Force writting changes even if no ebuild seems to satisfy the given atom. | ||
Force writting changes even if no ebuild seems to satisfy the given atom or | ||
none of the matched ebuilds seems to accept one of the given useflags. | ||
|
||
=item B<--dump> | ||
|
||
|
@@ -130,20 +131,28 @@ the --force (shortly -f) option to disable this behavior: | |
|
||
$ sudo chuse unexisting/package +foo -bar | ||
Error: This atom does not match any existing ebuild. Use --force option | ||
to proceed anyway | ||
to proceed anyway. | ||
$ sudo chuse -f unexisting/package +foo -bar | ||
|
||
As of version 1.2, useflags existence is also checked: | ||
|
||
$ sudo chuse dev-db/postgresql python -fanfan_la_tulipe dartagnan | ||
Error: No ebuild matched by the given atom accepts such use flags: | ||
dartagnan, fanfan_la_tulipe. Make sure you did not make a typo, or use | ||
--force option to proceed anyway. | ||
$ sudo chuse -f dev-db/postgresql python -fanfan_la_tulipe dartagnan | ||
|
||
=head1 BUGS | ||
|
||
Please report bugs on github L<https://github.com/apinsard/chuse/issues> | ||
Please report bugs on gitlab L<https://gitlab.com/apinsard/chuse/issues> | ||
|
||
=head1 AUTHOR | ||
|
||
Antoine Pinsard <[email protected]> | ||
|
||
=head1 VERSION | ||
|
||
1.1 | ||
1.2 | ||
|
||
=head1 SEE ALSO | ||
|
||
|