2020# CDDL HEADER END
2121#
2222# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
23+ # Copyright 2023 OmniOS Community Edition (OmniOSce) Association.
2324#
2425
2526# The portable module provide access to methods that require operating system-
2627# specific implementations. The module initialization logic selects the right
2728# implementation the module is loaded. The module methods then
28- # delegate to the implementation class object.
29+ # delegate to the implementation class object.
2930#
3031# The documentation for the methods is provided in this module. To support
3132# 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.
3334#
3435# The module and class must be named using os_[impl], where
3536# [impl] corresponds to the OS distro, name, or type of OS
3637# the class implements. For example, to add specific support
3738# for mandrake linux (above and beyond existing support for
3839# generic unix), one would create os_mandrake.py.
39- #
40+ #
4041# The following high-level groups of methods are defined in this module:
41- #
42+ #
4243# - Platform Attribute Methods: These methods give access to
4344# attributes of the underlying platform not available through
4445# existing python libraries. For example, the list of implemented
4546# ISAs of a given platform.
46- #
47+ #
4748# - Account access: Retrieval of account information (users and
4849# groups), in some cases for dormant, relocated OS images.
49- #
50+ #
5051# - Miscellaneous filesystem operations: common operations that
5152# 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().
5354
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
5657# redefines the methods with an OS-specific implementation.
5758
5859# Platform Methods
@@ -67,31 +68,37 @@ def get_release():
6768 must be a dot-separated set of integers (i.e. no alphabetic
6869 or punctuation)."""
6970 raise NotImplementedError
70-
71+
7172def get_platform ():
7273 """ Return a string representing the current hardware model
7374 information, e.g. "i86pc"."""
7475 raise NotImplementedError
7576
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."""
7885 raise NotImplementedError
7986
8087# Account access
8188# --------------
8289def get_group_by_name (name , dirpath , use_file ):
8390 """ Return the group ID for a group name.
8491 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
8693 group ID is retrieved from the operating system.
87- Exceptions:
94+ Exceptions:
8895 KeyError if the specified group does not exist"""
8996 raise NotImplementedError
9097
9198def get_user_by_name (name , dirpath , use_file ):
9299 """ Return the user ID for a user name.
93100 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
95102 user ID is retrieved from the operating system.
96103 Exceptions:
97104 KeyError if the specified group does not exist"""
@@ -100,7 +107,7 @@ def get_user_by_name(name, dirpath, use_file):
100107def get_name_by_gid (gid , dirpath , use_file ):
101108 """ Return the group name for a group ID.
102109 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
104111 group name is retrieved from the operating system.
105112 Exceptions:
106113 KeyError if the specified group does not exist"""
@@ -109,7 +116,7 @@ def get_name_by_gid(gid, dirpath, use_file):
109116def get_name_by_uid (uid , dirpath , use_file ):
110117 """ Return the user name for a user ID.
111118 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
113120 user name is retrieved from the operating system.
114121 Exceptions:
115122 KeyError if the specified group does not exist"""
@@ -144,7 +151,7 @@ def chown(path, owner, group):
144151 """ Change ownership of a file in an OS-specific way.
145152 The owner and group ownership information should be applied to
146153 the given file, if applicable on the current runtime OS.
147- Exceptions:
154+ Exceptions:
148155 EnvironmentError (or subclass) if the path does not exist
149156 or ownership cannot be changed"""
150157 raise NotImplementedError
@@ -167,7 +174,7 @@ def link(src, dst):
167174def remove (path ):
168175 """ Remove the given file in an OS-specific way
169176 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
171178 the file cannot be removed"""
172179 raise NotImplementedError
173180
@@ -183,7 +190,7 @@ def copyfile(src, dst):
183190 raise NotImplementedError
184191
185192def 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.
187194 This is intended to hide platform-specific details about splitting
188195 a path into its components. This interface is similar to
189196 os.path.split() except that the entire path is split, not just
@@ -195,7 +202,7 @@ def split_path(path):
195202 raise NotImplementedError
196203
197204def get_root (path ):
198- """ Returns the 'root' of the given path.
205+ """ Returns the 'root' of the given path.
199206 This should include any and all components of a path up to the first
200207 non-platform-specific component. For example, on Windows,
201208 it should include the drive letter prefix.
@@ -208,7 +215,7 @@ def get_root(path):
208215def assert_mode (path , mode ):
209216 """ Checks that the file identified by path has the given mode to
210217 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
212219 mode of the file."""
213220 raise NotImplementedError
214221
@@ -231,7 +238,8 @@ def get_sysattr_dict():
231238
232239# File type constants
233240# -------------------
234- ELF , EXEC , UNFOUND , SMF_MANIFEST = range (0 , 4 )
241+ ELF , EXEC , UNFOUND , SMF_MANIFEST , XMLDOC , EMPTYFILE , NOTFILE , UNKNOWN = \
242+ range (0 , 8 )
235243
236244# String to be used for an action attribute created for the internal use of
237245# dependency analysis.
@@ -267,7 +275,7 @@ def get_sysattr_dict():
267275
268276 # try the most-specific module name first (e.g. os_suse),
269277 # 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)
271279 try :
272280 exec ('from .{0} import *' .format (modname ))
273281 break
0 commit comments