Changeset 06c4ed1 in trunk
- Timestamp:
- 2021-04-12T13:28:51Z (4 years ago)
- Branches:
- master
- Children:
- 069fcb9
- Parents:
- d6406d5
- Location:
- src/allmydata/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/scripts/common.py ¶
rd6406d5 r06c4ed1 2 2 3 3 from __future__ import print_function 4 from six import ensure_ binary4 from six import ensure_str 5 5 6 6 import os, sys, textwrap … … 277 277 278 278 def escape_path(path): 279 # type: (Union[str,bytes]) -> bytes279 # type: (Union[str,bytes]) -> str 280 280 u""" 281 281 Return path quoted to US-ASCII, valid URL characters. … … 284 284 >>> escaped = escape_path(path) 285 285 >>> escaped 286 b'/f%C3%B8%C3%B6/bar/%E2%98%83'286 u'/f%C3%B8%C3%B6/bar/%E2%98%83' 287 287 """ 288 288 if isinstance(path, str): 289 289 path = path.encode("utf-8") 290 290 segments = path.split(b"/") 291 return b"/".join([urllib.parse.quote(s).encode("ascii") for s in segments]) 292 291 result = str( 292 b"/".join([ 293 urllib.parse.quote(s).encode("ascii") for s in segments 294 ]), 295 "ascii" 296 ) 297 # Eventually (i.e. as part of Python 3 port) we want this to always return 298 # Unicode strings. However, to reduce diff sizes in the short term it'll 299 # return native string (i.e. bytes) on Python 2. 300 if PY2: 301 result = result.encode("ascii").__native__() 302 return result -
TabularUnified src/allmydata/scripts/tahoe_backup.py ¶
rd6406d5 r06c4ed1 1 1 from __future__ import print_function 2 3 from past.builtins import unicode 2 4 3 5 import os.path … … 346 348 return target.backup(progress, upload_file, upload_directory) 347 349 else: 348 assert isinstance(childcap, str)350 assert isinstance(childcap, bytes) 349 351 if created: 350 352 return progress.created_file(self._path, childcap, metadata) … … 526 528 os.path.basename(create_path): create_value 527 529 for (create_path, create_value) 528 in self._create_contents.ite ritems()530 in self._create_contents.items() 529 531 if os.path.dirname(create_path) == dirpath 530 532 }, { 531 533 os.path.basename(compare_path): compare_value 532 534 for (compare_path, compare_value) 533 in self._compare_contents.ite ritems()535 in self._compare_contents.items() 534 536 if os.path.dirname(compare_path) == dirpath 535 537 }
Note: See TracChangeset
for help on using the changeset viewer.