Mercurial > hgrepos > Python > apps > py-cutils
annotate cutils/util/constants.py @ 361:26b949727426
>>>>> tag v0.8.1 for changeset 7b715f912ea8
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 02 Apr 2025 14:27:08 +0200 |
| parents | 48430941c18c |
| children |
| rev | line source |
|---|---|
|
117
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 # :- |
|
323
48430941c18c
Adopt copyright and license wordings from https://reuse.software/faq/.
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
3 # SPDX-FileCopyrightText: © 2024-2025 Franz Glasner |
|
48430941c18c
Adopt copyright and license wordings from https://reuse.software/faq/.
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
4 # SPDX-License-Identifier: BSD-3-Clause |
|
117
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
5 # :- |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
6 r"""Common constants and compatibility definitions. |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
7 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
8 """ |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 |
|
196
0f4febf646f5
Prepare for more Python2/3 compatibility: everywhere import print_function and absolute_import
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
10 from __future__ import print_function, absolute_import |
|
0f4febf646f5
Prepare for more Python2/3 compatibility: everywhere import print_function and absolute_import
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
11 |
|
0f4febf646f5
Prepare for more Python2/3 compatibility: everywhere import print_function and absolute_import
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
12 |
|
164
a813094ae4f5
Move PY2 from cutils.util.constants into cutils.util
Franz Glasner <fzglas.hg@dom66.de>
parents:
126
diff
changeset
|
13 __all__ = ["PATH_TYPES", |
|
117
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 "READ_CHUNK_SIZE", |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 "MAX_AUTO_MAP_SIZE", |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 "MAP_WINDOW_SIZE" |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 ] |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
18 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
20 try: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 import pathlib |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
22 except ImportError: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 pathlib = None |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 |
|
164
a813094ae4f5
Move PY2 from cutils.util.constants into cutils.util
Franz Glasner <fzglas.hg@dom66.de>
parents:
126
diff
changeset
|
25 from . import PY2 |
|
117
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
27 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
28 if PY2: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
29 PATH_TYPES = (unicode, str) # noqa: F821 (undefined name 'unicode') |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
30 else: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
31 if pathlib: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 PATH_TYPES = (str, bytes, pathlib.Path) |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 else: |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
34 PATH_TYPES = (str, bytes) |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
35 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
36 READ_CHUNK_SIZE = 2 * 1024 * 1024 # like BUFSIZE_MAX on FreeBSD |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
37 MAX_AUTO_MAP_SIZE = 8 * 1024 * 1024 |
|
e51f34ad6d71
Move constant definitions into new module cutils.util.constants
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
38 MAP_WINDOW_SIZE = MAX_AUTO_MAP_SIZE # do not totally trash memory on big files |
