20
20
# CDDL HEADER END
21
21
#
22
22
# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
23
+ # Copyright 2023 OmniOS Community Edition (OmniOSce) Association.
23
24
#
24
25
25
26
# The portable module provide access to methods that require operating system-
26
27
# specific implementations. The module initialization logic selects the right
27
28
# implementation the module is loaded. The module methods then
28
- # delegate to the implementation class object.
29
+ # delegate to the implementation class object.
29
30
#
30
31
# The documentation for the methods is provided in this module. To support
31
32
# another operating system, each of these methods must be implemented by the
32
- # class for that operating system even if it is effectively a no-op.
33
+ # class for that operating system even if it is effectively a no-op.
33
34
#
34
35
# The module and class must be named using os_[impl], where
35
36
# [impl] corresponds to the OS distro, name, or type of OS
36
37
# the class implements. For example, to add specific support
37
38
# for mandrake linux (above and beyond existing support for
38
39
# generic unix), one would create os_mandrake.py.
39
- #
40
+ #
40
41
# The following high-level groups of methods are defined in this module:
41
- #
42
+ #
42
43
# - Platform Attribute Methods: These methods give access to
43
44
# attributes of the underlying platform not available through
44
45
# existing python libraries. For example, the list of implemented
45
46
# ISAs of a given platform.
46
- #
47
+ #
47
48
# - Account access: Retrieval of account information (users and
48
49
# groups), in some cases for dormant, relocated OS images.
49
- #
50
+ #
50
51
# - Miscellaneous filesystem operations: common operations that
51
52
# differ in implementation or are only available on a subset
52
- # of OS or filesystem implementations, such as chown() or rename().
53
+ # of OS or filesystem implementations, such as chown() or rename().
53
54
54
- # This module exports the methods defined below. They are defined here as
55
- # not implemented to avoid pylint errors. The included OS-specific module
55
+ # This module exports the methods defined below. They are defined here as
56
+ # not implemented to avoid pylint errors. The included OS-specific module
56
57
# redefines the methods with an OS-specific implementation.
57
58
58
59
# Platform Methods
@@ -67,31 +68,37 @@ def get_release():
67
68
must be a dot-separated set of integers (i.e. no alphabetic
68
69
or punctuation)."""
69
70
raise NotImplementedError
70
-
71
+
71
72
def get_platform ():
72
73
""" Return a string representing the current hardware model
73
74
information, e.g. "i86pc"."""
74
75
raise NotImplementedError
75
76
76
- def get_file_type (actions ):
77
- """ Return a list containing the file type for each file in paths."""
77
+ def get_file_type (path ):
78
+ """ Return a value indicating the type of file found at path.
79
+ The return value is one of file type constants defined below."""
80
+ raise NotImplementedError
81
+
82
+ def get_actions_file_type (actions ):
83
+ """ Return an iterator or list containing the file type for each file
84
+ in the list of provided actions."""
78
85
raise NotImplementedError
79
86
80
87
# Account access
81
88
# --------------
82
89
def get_group_by_name (name , dirpath , use_file ):
83
90
""" Return the group ID for a group name.
84
91
If use_file is true, an OS-specific file from within the file tree
85
- rooted by dirpath will be consulted, if it exists. Otherwise, the
92
+ rooted by dirpath will be consulted, if it exists. Otherwise, the
86
93
group ID is retrieved from the operating system.
87
- Exceptions:
94
+ Exceptions:
88
95
KeyError if the specified group does not exist"""
89
96
raise NotImplementedError
90
97
91
98
def get_user_by_name (name , dirpath , use_file ):
92
99
""" Return the user ID for a user name.
93
100
If use_file is true, an OS-specific file from within the file tree
94
- rooted by dirpath will be consulted, if it exists. Otherwise, the
101
+ rooted by dirpath will be consulted, if it exists. Otherwise, the
95
102
user ID is retrieved from the operating system.
96
103
Exceptions:
97
104
KeyError if the specified group does not exist"""
@@ -100,7 +107,7 @@ def get_user_by_name(name, dirpath, use_file):
100
107
def get_name_by_gid (gid , dirpath , use_file ):
101
108
""" Return the group name for a group ID.
102
109
If use_file is true, an OS-specific file from within the file tree
103
- rooted by dirpath will be consulted, if it exists. Otherwise, the
110
+ rooted by dirpath will be consulted, if it exists. Otherwise, the
104
111
group name is retrieved from the operating system.
105
112
Exceptions:
106
113
KeyError if the specified group does not exist"""
@@ -109,7 +116,7 @@ def get_name_by_gid(gid, dirpath, use_file):
109
116
def get_name_by_uid (uid , dirpath , use_file ):
110
117
""" Return the user name for a user ID.
111
118
If use_file is true, an OS-specific file from within the file tree
112
- rooted by dirpath will be consulted, if it exists. Otherwise, the
119
+ rooted by dirpath will be consulted, if it exists. Otherwise, the
113
120
user name is retrieved from the operating system.
114
121
Exceptions:
115
122
KeyError if the specified group does not exist"""
@@ -144,7 +151,7 @@ def chown(path, owner, group):
144
151
""" Change ownership of a file in an OS-specific way.
145
152
The owner and group ownership information should be applied to
146
153
the given file, if applicable on the current runtime OS.
147
- Exceptions:
154
+ Exceptions:
148
155
EnvironmentError (or subclass) if the path does not exist
149
156
or ownership cannot be changed"""
150
157
raise NotImplementedError
@@ -167,7 +174,7 @@ def link(src, dst):
167
174
def remove (path ):
168
175
""" Remove the given file in an OS-specific way
169
176
Exceptions:
170
- OSError (or subclass) if the source path does not exist or
177
+ OSError (or subclass) if the source path does not exist or
171
178
the file cannot be removed"""
172
179
raise NotImplementedError
173
180
@@ -183,7 +190,7 @@ def copyfile(src, dst):
183
190
raise NotImplementedError
184
191
185
192
def split_path (path ):
186
- """ Splits a path and gives back the components of the path.
193
+ """ Splits a path and gives back the components of the path.
187
194
This is intended to hide platform-specific details about splitting
188
195
a path into its components. This interface is similar to
189
196
os.path.split() except that the entire path is split, not just
@@ -195,7 +202,7 @@ def split_path(path):
195
202
raise NotImplementedError
196
203
197
204
def get_root (path ):
198
- """ Returns the 'root' of the given path.
205
+ """ Returns the 'root' of the given path.
199
206
This should include any and all components of a path up to the first
200
207
non-platform-specific component. For example, on Windows,
201
208
it should include the drive letter prefix.
@@ -208,7 +215,7 @@ def get_root(path):
208
215
def assert_mode (path , mode ):
209
216
""" Checks that the file identified by path has the given mode to
210
217
the extent possible by the host operating system. Otherwise raises
211
- an AssertionError where the mode attribute of the assertion is the
218
+ an AssertionError where the mode attribute of the assertion is the
212
219
mode of the file."""
213
220
raise NotImplementedError
214
221
@@ -231,7 +238,8 @@ def get_sysattr_dict():
231
238
232
239
# File type constants
233
240
# -------------------
234
- ELF , EXEC , UNFOUND , SMF_MANIFEST = range (0 , 4 )
241
+ ELF , EXEC , UNFOUND , SMF_MANIFEST , XMLDOC , EMPTYFILE , NOTFILE , UNKNOWN = \
242
+ range (0 , 8 )
235
243
236
244
# String to be used for an action attribute created for the internal use of
237
245
# dependency analysis.
@@ -267,7 +275,7 @@ def get_sysattr_dict():
267
275
268
276
# try the most-specific module name first (e.g. os_suse),
269
277
# then try the more generic OS Name module (e.g. os_linux),
270
- # then the OS type module (e.g. os_unix)
278
+ # then the OS type module (e.g. os_unix)
271
279
try :
272
280
exec ('from .{0} import *' .format (modname ))
273
281
break
0 commit comments