Mercurial > hg
comparison mercurial/pure/osutil.py @ 30642:e995f00a9e9a
py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 19 Dec 2016 02:26:41 +0530 |
parents | d524c88511a7 |
children | 82f1ef8b4477 |
comparison
equal
deleted
inserted
replaced
30641:16b5df5792a8 | 30642:e995f00a9e9a |
---|---|
10 import ctypes | 10 import ctypes |
11 import ctypes.util | 11 import ctypes.util |
12 import os | 12 import os |
13 import socket | 13 import socket |
14 import stat as statmod | 14 import stat as statmod |
15 import sys | |
16 | 15 |
17 from . import ( | 16 from . import ( |
18 policy, | 17 policy, |
19 pycompat, | 18 pycompat, |
20 ) | 19 ) |
68 else: | 67 else: |
69 result.append((fn, _mode_to_kind(st.st_mode))) | 68 result.append((fn, _mode_to_kind(st.st_mode))) |
70 return result | 69 return result |
71 | 70 |
72 ffi = None | 71 ffi = None |
73 if modulepolicy not in policynocffi and sys.platform == 'darwin': | 72 if modulepolicy not in policynocffi and pycompat.sysplatform == 'darwin': |
74 try: | 73 try: |
75 from _osutil_cffi import ffi, lib | 74 from _osutil_cffi import ffi, lib |
76 except ImportError: | 75 except ImportError: |
77 if modulepolicy == 'cffi': # strict cffi import | 76 if modulepolicy == 'cffi': # strict cffi import |
78 raise | 77 raise |
79 | 78 |
80 if sys.platform == 'darwin' and ffi is not None: | 79 if pycompat.sysplatform == 'darwin' and ffi is not None: |
81 listdir_batch_size = 4096 | 80 listdir_batch_size = 4096 |
82 # tweakable number, only affects performance, which chunks | 81 # tweakable number, only affects performance, which chunks |
83 # of bytes do we get back from getattrlistbulk | 82 # of bytes do we get back from getattrlistbulk |
84 | 83 |
85 attrkinds = [None] * 20 # we need the max no for enum VXXX, 20 is plenty | 84 attrkinds = [None] * 20 # we need the max no for enum VXXX, 20 is plenty |
163 posixfile = open | 162 posixfile = open |
164 | 163 |
165 _SCM_RIGHTS = 0x01 | 164 _SCM_RIGHTS = 0x01 |
166 _socklen_t = ctypes.c_uint | 165 _socklen_t = ctypes.c_uint |
167 | 166 |
168 if sys.platform == 'linux2': | 167 if pycompat.sysplatform.startswith('linux'): |
169 # socket.h says "the type should be socklen_t but the definition of | 168 # socket.h says "the type should be socklen_t but the definition of |
170 # the kernel is incompatible with this." | 169 # the kernel is incompatible with this." |
171 _cmsg_len_t = ctypes.c_size_t | 170 _cmsg_len_t = ctypes.c_size_t |
172 _msg_controllen_t = ctypes.c_size_t | 171 _msg_controllen_t = ctypes.c_size_t |
173 _msg_iovlen_t = ctypes.c_size_t | 172 _msg_iovlen_t = ctypes.c_size_t |