def make_flags_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class("flags", [ "bytes_warning", "debug", "dont_write_bytecode", "hash_randomization", "ignore_environment", "inspect", "interactive", "isolated", "no_site", "no_user_site", "optimize", "quiet", "verbose" ])
def make_int_info_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class( "int_info", ["bits_per_digit", "sizeof_digit"] )
def make_implementation_info(): from _descriptor import SimpleNamespace, make_named_tuple_class version_info_type = make_named_tuple_class( "version_info", ["major", "minor", "micro", "releaselevel", "serial"]) return SimpleNamespace(name="graalpython", cache_tag="graalpython", version=version_info_type(version_info), _multiarch=__gmultiarch)
def make_implementation_info(): from _descriptor import SimpleNamespace, make_named_tuple_class version_info_type = make_named_tuple_class( "version_info", ["major", "minor", "micro", "releaselevel", "serial"]) _version = version_info_type(version_info) result = SimpleNamespace(name="graalpython", cache_tag="graalpython-" + str(_version.major) + str(_version.minor), version=_version, _multiarch=__gmultiarch) version_info_type.seal() return result
def make_hash_info_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class( "hash_info", ["algorithm", "cutoff", "hash_bits", "imag", "inf", "modulus", "nan", "seed_bits", "width"] )
def make_float_info_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class( "float_info", ["max", "max_exp", "max_10_exp", "min", "min_exp", "min_10_exp", "dig", "mant_dig", "epsilon", "radix", "rounds"] )
def make_struct_time(): from _descriptor import make_named_tuple_class fields = [ "tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst" ] struct_time_type = make_named_tuple_class("struct_time", fields) class struct_time(struct_time_type): def __new__(cls, iterable): def create_struct(iter, zone, gmtoff): result = tuple.__new__(cls, iter) result.tm_zone = zone result.tm_gmtoff = gmtoff return result count = len(iterable) if (count < 9): raise TypeError( "time.struct_time() takes an at least 9-sequence (%d-sequence given)" % count) if (count > 11): raise TypeError( "time.struct_time() takes an at most 11-sequence (%d-sequence given)" % count) if count == 11: return create_struct(iterable[0:9], iterable[9], iterable[10]) if count == 10: return create_struct(iterable[0:9], iterable[9], None) if count == 9: return create_struct(iterable, None, None) def __repr__(self): text = "{}(".format(self.__class__.__name__) n = len(self) for i in range(n): if self[i] != None: if i > 0: text = text + ", " text = text + "{}={}".format(fields[i], str(self[i])) text = text + ')' return text return struct_time
def make_flags_class(): from _descriptor import make_named_tuple_class get_set_descriptor = type(type(make_flags_class).__code__) names = ["bytes_warning", "debug", "dont_write_bytecode", "hash_randomization", "ignore_environment", "inspect", "interactive", "isolated", "no_site", "no_user_site", "optimize", "quiet", "verbose", "dev_mode", "utf8_mode"] flags_class = make_named_tuple_class("sys.flags", names) def make_func(i): def func(self): return __flags__[i] return func for i, f in enumerate(names): setattr(flags_class, f, get_set_descriptor(fget=make_func(i), name=f, owner=flags_class)) return flags_class
# Software and the Larger Work(s), and to sublicense the foregoing rights on # either these or other terms. # # This license is subject to the following condition: # # The above copyright notice and either this complete permission notice or at a # minimum a reference to the UPL must be included in all copies or substantial # portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from _descriptor import make_named_tuple_class passwd_result = make_named_tuple_class("passwd_result", [ "pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell" ]) old_getpwuid = getpwuid @__builtin__ def getpwuid(uid): return passwd_result(old_getpwuid(uid))
def make_unraisable_hook_args_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class( "UnraisableHookArgs", ["exc_type", "exc_value", "exc_traceback", "err_msg", "object"], )
def make_thread_info_class(): from _descriptor import make_named_tuple_class return make_named_tuple_class("thread_info", ["name", "lock", "version"])
# minimum a reference to the UPL must be included in all copies or substantial # portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from _descriptor import make_named_tuple_class stat_result = make_named_tuple_class("stat_result", [ "st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size", "st_atime", "st_mtime", "st_ctime" ]) del make_named_tuple_class old_stat = stat def stat(filename): return stat_result(old_stat(filename)) def lstat(filename): return stat_result(old_stat(filename, False))
# The above copyright notice and either this complete permission notice or at a # minimum a reference to the UPL must be included in all copies or substantial # portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from _descriptor import make_named_tuple_class stat_result = make_named_tuple_class("stat_result", [ "st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size", "st_atime", "st_mtime", "st_ctime" ]) stat_result.st_atime_ns = property(lambda s: int(s.st_atime * 1000)) stat_result.st_mtime_ns = property(lambda s: int(s.st_mtime * 1000)) old_stat = stat @__graalpython__.builtin def stat(filename, follow_symlinks=True): return stat_result(old_stat(filename, follow_symlinks=follow_symlinks)) __dir_entry_old_stat = DirEntry.stat
# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from _descriptor import make_named_tuple_class profiler_entry = make_named_tuple_class( "profiler_entry", ["code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls"] ) profiler_subentry = make_named_tuple_class( "profiler_subentry", ["code", "callcount", "reccallcount", "totaltime", "inlinetime"] )
# # The above copyright notice and either this complete permission notice or at a # minimum a reference to the UPL must be included in all copies or substantial # portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. RUSAGE_CHILDREN = -1 RUSAGE_SELF = 0 RUSAGE_THREAD = 1 from _descriptor import make_named_tuple_class ru_result = make_named_tuple_class("ru_result", [ "ru_utime", "ru_stime", "ru_maxrss", "ru_ixrss", "ru_idrss", "ru_isrss", "ru_minflt", "ru_majflt", "ru_nswap", "ru_inblock", "ru_oublock", "ru_msgsnd", "ru_msgrcv", "ru_nsignals", "ru_nvcsw", "ru_nivcsw" ]) old_getrusage = getrusage @__builtin__ def getrusage(who): return ru_result(old_getrusage(who))