Changeset 11b93412 in trunk


Ignore:
Timestamp:
2020-08-11T19:49:59Z (5 years ago)
Author:
Itamar Turner-Trauring <itamar@…>
Branches:
master
Children:
2772980
Parents:
babe2db
Message:

Port to Python 3.

Location:
src/allmydata/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/util/_python3.py

    rbabe2db r11b93412  
    2929    "allmydata.util.base32",
    3030    "allmydata.util.base62",
     31    "allmydata.util.configutil",
    3132    "allmydata.util.connection_status",
    3233    "allmydata.util.deferredutil",
  • TabularUnified src/allmydata/util/configutil.py

    rbabe2db r11b93412  
     1from __future__ import absolute_import
     2from __future__ import division
     3from __future__ import print_function
     4from __future__ import unicode_literals
    15
    2 from ConfigParser import SafeConfigParser
     6from future.utils import PY2
     7if PY2:
     8    from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min  # noqa: F401
     9
     10from configparser import SafeConfigParser
    311
    412import attr
     
    1422def get_config(tahoe_cfg):
    1523    config = SafeConfigParser()
    16     with open(tahoe_cfg, "rb") as f:
    17         # Skip any initial Byte Order Mark. Since this is an ordinary file, we
    18         # don't need to handle incomplete reads, and can assume seekability.
    19         if f.read(3) != '\xEF\xBB\xBF':
    20             f.seek(0)
     24    with open(tahoe_cfg, "r") as f:
    2125        config.readfp(f)
    2226    return config
     
    2933
    3034def write_config(tahoe_cfg, config):
    31     with open(tahoe_cfg, "wb") as f:
     35    with open(tahoe_cfg, "w") as f:
    3236        config.write(f)
    3337
Note: See TracChangeset for help on using the changeset viewer.