Changeset 1877:a07e12d6fdfb


Ignore:
Timestamp:
Jan 1, 2020, 5:34:58 PM (3 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Change argument `content_source` to `path`

The latter is clearer and in line with the upcoming changes of
arguments that are currently used for strings, but will also allow
`PathLike` values.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/tool.py

    r1876 r1877  
    2323
    2424
    25 def same_string_type_as(type_source, content_source):
     25def same_string_type_as(type_source, path):
    2626    """
    2727    Return a string of the same type as `type_source` with the content
    28     from `content_source`.
     28    from `path`.
    2929
    3030    `type_source` may be a `PathLike` object. In that case, the type
     
    3737    """
    3838    actual_type_source = os.fspath(type_source)
    39     if isinstance(actual_type_source, bytes) and isinstance(content_source, str):
    40         return content_source.encode(LOSSLESS_ENCODING)
    41     elif isinstance(actual_type_source, str) and isinstance(content_source, bytes):
    42         return content_source.decode(LOSSLESS_ENCODING)
     39    if isinstance(actual_type_source, bytes) and isinstance(path, str):
     40        return path.encode(LOSSLESS_ENCODING)
     41    elif isinstance(actual_type_source, str) and isinstance(path, bytes):
     42        return path.decode(LOSSLESS_ENCODING)
    4343    else:
    44         return content_source
     44        return path
    4545
    4646
Note: See TracChangeset for help on using the changeset viewer.