10
10
from inspect import cleandoc
11
11
from os import environ , makedirs
12
12
from os .path import basename , dirname , expanduser , join as pjoin , realpath
13
- from sys import exit , argv , path , platform , hexversion , version_info
13
+ from sys import exit , argv , path , platform , hexversion , version_info , executable
14
14
15
15
_path = dirname (realpath (__file__ ))
16
16
if _path not in path :
19
19
import mountinfo
20
20
21
21
windows = platform in {'win32' , 'cygwin' }
22
+ macos = platform == 'darwin'
22
23
23
24
python_cmd = 'py -3' if windows else 'python3'
24
25
25
26
if hexversion < 0x030800F0 :
26
27
exit ('Python {0[0]}.{0[1]}.{0[2]} is not supported. Please use Python 3.8.0 or later.' .format (version_info ))
27
28
28
29
30
+ def print_version ():
31
+ from __init__ import __version__
32
+ pyver = '{0[0]}.{0[1]}.{0[2]}' .format (version_info )
33
+ if version_info [3 ] != 'final' :
34
+ pyver += '{0[3][0]}{0[4]}' .format (version_info )
35
+ # this should stay as str.format, so it runs on older versions
36
+ print ('ninfs v{0} on Python {1} - https://github.com/ihaveamac/ninfs' .format (__version__ , pyver ))
37
+
38
+
29
39
def exit_print_types ():
30
40
print ('Please provide a mount type as the first argument.' )
31
41
print ('Available mount types:' )
@@ -35,6 +45,10 @@ def exit_print_types():
35
45
for item in items :
36
46
info = mountinfo .get_type_info (item )
37
47
print (f' - { item } : { info ["name" ]} ({ info ["info" ]} )' )
48
+ print ()
49
+ print ('Additional options:' )
50
+ print (' --version print version' )
51
+ print (' --install-desktop-entry [PREFIX] create desktop entry (for Linux)' )
38
52
exit (1 )
39
53
40
54
@@ -45,12 +59,7 @@ def mount(mount_type: str, return_doc: bool = False) -> int:
45
59
46
60
if mount_type in {'-v' , '--version' }:
47
61
# this kinda feels wrong...
48
- from __init__ import __version__
49
- pyver = '{0[0]}.{0[1]}.{0[2]}' .format (version_info )
50
- if version_info [3 ] != 'final' :
51
- pyver += '{0[3][0]}{0[4]}' .format (version_info )
52
- # this should stay as str.format so it runs on older versions
53
- print ('ninfs v{0} on Python {1} - https://github.com/ihaveamac/ninfs' .format (__version__ , pyver ))
62
+ print_version ()
54
63
return 0
55
64
56
65
# noinspection PyProtectedMember
@@ -75,6 +84,7 @@ def mount(mount_type: str, return_doc: bool = False) -> int:
75
84
pass
76
85
77
86
if mount_type not in mountinfo .types and mount_type not in mountinfo .aliases :
87
+ print_version ()
78
88
exit_print_types ()
79
89
80
90
module = import_module ('mount.' + mountinfo .aliases .get (mount_type , mount_type ))
@@ -100,11 +110,14 @@ def mount(mount_type: str, return_doc: bool = False) -> int:
100
110
101
111
102
112
def create_desktop_entry (prefix : str = None ):
103
- desktop_file = cleandoc ('''
113
+ if windows or macos :
114
+ print ('This command is not supported for Windows or macOS.' )
115
+ return
116
+ desktop_file = cleandoc (f'''
104
117
[Desktop Entry]
105
118
Name=ninfs
106
119
Comment=Mount Nintendo contents
107
- Exec=python3 -mninfs gui
120
+ Exec=" { executable } " -mninfs gui
108
121
Terminal=true
109
122
Type=Application
110
123
Icon=ninfs
0 commit comments