Changeset 9ed0cd42 in trunk
- Timestamp:
- 2021-06-03T13:08:13Z (4 years ago)
- Branches:
- master
- Children:
- aef8705, e2831ee
- Parents:
- 336ca45c (diff), a910ebcc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Itamar Turner-Trauring <itamar@…> (2021-06-03 13:08:13)
- git-committer:
- GitHub <noreply@…> (2021-06-03 13:08:13)
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/scripts/cli.py ¶
r336ca45c r9ed0cd42 516 516 def list_(options): 517 517 from allmydata.scripts import tahoe_ls 518 rc = tahoe_ls.l ist(options)518 rc = tahoe_ls.ls(options) 519 519 return rc 520 520 -
TabularUnified src/allmydata/scripts/tahoe_cp.py ¶
r336ca45c r9ed0cd42 1 """ 2 Ported to Python 3. 3 """ 4 from __future__ import unicode_literals 5 from __future__ import absolute_import 6 from __future__ import division 1 7 from __future__ import print_function 2 8 3 from past.builtins import unicode 9 from future.utils import PY2 10 if PY2: 11 from future.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 4 12 5 13 import os.path … … 163 171 164 172 def get_child_target(self, name): 165 precondition(isinstance(name, unicode), name)173 precondition(isinstance(name, str), name) 166 174 precondition(len(name), name) # don't want "" 167 175 if self.children is None: … … 176 184 177 185 def put_file(self, name, inf): 178 precondition(isinstance(name, unicode), name)186 precondition(isinstance(name, str), name) 179 187 pathname = os.path.join(self.pathname, name) 180 188 fileutil.put_file(pathname, inf) … … 259 267 assert nodetype == "dirnode" 260 268 self.mutable = d.get("mutable", False) # older nodes don't provide it 261 self.children_d = dict( [( unicode(name),value)269 self.children_d = dict( [(str(name),value) 262 270 for (name,value) 263 271 in d["children"].items()] ) … … 269 277 self.readcap = to_bytes(d.get("ro_uri")) 270 278 self.mutable = d.get("mutable", False) # older nodes don't provide it 271 self.children_d = dict( [( unicode(name),value)279 self.children_d = dict( [(str(name),value) 272 280 for (name,value) 273 281 in d["children"].items()] ) … … 339 347 self.readcap = to_bytes(d.get("ro_uri")) 340 348 self.mutable = d.get("mutable", False) # older nodes don't provide it 341 self.children_d = dict( [( unicode(name),value)349 self.children_d = dict( [(str(name),value) 342 350 for (name,value) 343 351 in d["children"].items()] ) … … 356 364 assert nodetype == "dirnode" 357 365 self.mutable = d.get("mutable", False) # older nodes don't provide it 358 self.children_d = dict( [( unicode(name),value)366 self.children_d = dict( [(str(name),value) 359 367 for (name,value) 360 368 in d["children"].items()] ) … … 412 420 def get_child_target(self, name): 413 421 # return a new target for a named subdirectory of this dir 414 precondition(isinstance(name, unicode), name)422 precondition(isinstance(name, str), name) 415 423 if self.children is None: 416 424 self.populate(recurse=False) … … 425 433 426 434 def put_file(self, name, inf): 427 precondition(isinstance(name, unicode), name)435 precondition(isinstance(name, str), name) 428 436 url = self.nodeurl + "uri" 429 437 if not seekable(inf): … … 445 453 446 454 def put_uri(self, name, filecap): 447 precondition(isinstance(name, unicode), name)455 precondition(isinstance(name, str), name) 448 456 self.new_children[name] = filecap 449 457 … … 454 462 + "?t=set_children") 455 463 set_data = {} 456 for (name, filecap) in self.new_children.items():464 for (name, filecap) in list(self.new_children.items()): 457 465 # it just so happens that ?t=set_children will accept both file 458 466 # read-caps and write-caps as ['rw_uri'], and will handle either … … 598 606 599 607 def get_target_info(self, destination_spec): 600 precondition(isinstance(destination_spec, unicode), destination_spec)608 precondition(isinstance(destination_spec, str), destination_spec) 601 609 rootcap, path_utf8 = get_alias(self.aliases, destination_spec, None) 602 610 path = path_utf8.decode("utf-8") … … 645 653 This turns an argv string into a (Local|Tahoe)(File|Directory)Source. 646 654 """ 647 precondition(isinstance(source_spec, unicode), source_spec)655 precondition(isinstance(source_spec, str), source_spec) 648 656 rootcap, path_utf8 = get_alias(self.aliases, source_spec, None) 649 657 path = path_utf8.decode("utf-8") … … 753 761 # target name collisions are an error 754 762 collisions = [] 755 for target, sources in targetmap.items():763 for target, sources in list(targetmap.items()): 756 764 target_names = {} 757 765 for source in sources: … … 822 830 # copy everything in the source into the target 823 831 precondition(isinstance(source, DirectorySources), source) 824 for name, child in source.children.items():832 for name, child in list(source.children.items()): 825 833 if isinstance(child, DirectorySources): 826 834 # we will need a target directory for this one … … 838 846 targets_finished = 0 839 847 840 for target, sources in targetmap.items():848 for target, sources in list(targetmap.items()): 841 849 _assert(isinstance(target, DirectoryTargets), target) 842 850 for source in sources: … … 858 866 precondition(isinstance(source, FileSources), source) 859 867 precondition(isinstance(target, DirectoryTargets), target) 860 precondition(isinstance(name, unicode), name)868 precondition(isinstance(name, str), name) 861 869 if self.need_to_copy_bytes(source, target): 862 870 # if the target is a local directory, this will just write the -
TabularUnified src/allmydata/scripts/tahoe_get.py ¶
r336ca45c r9ed0cd42 1 """ 2 Ported to Python 3. 3 """ 4 from __future__ import unicode_literals 5 from __future__ import absolute_import 6 from __future__ import division 1 7 from __future__ import print_function 2 8 3 from future.utils import PY3 9 from future.utils import PY2, PY3 10 if PY2: 11 from future.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 4 12 5 13 from urllib.parse import quote as url_quote -
TabularUnified src/allmydata/scripts/tahoe_invite.py ¶
r336ca45c r9ed0cd42 1 """ 2 Ported to Python 3. 3 """ 4 from __future__ import unicode_literals 5 from __future__ import absolute_import 6 from __future__ import division 1 7 from __future__ import print_function 8 9 from future.utils import PY2 10 if PY2: 11 from future.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 2 12 3 13 try: -
TabularUnified src/allmydata/scripts/tahoe_ls.py ¶
r336ca45c r9ed0cd42 1 """ 2 Ported to Python 3. 3 """ 4 from __future__ import unicode_literals 5 from __future__ import absolute_import 6 from __future__ import division 1 7 from __future__ import print_function 2 8 3 from past.builtins import unicode 4 from six import ensure_text, ensure_str 9 from future.utils import PY2 10 if PY2: 11 from future.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 12 13 from six import ensure_text 5 14 6 15 import time … … 12 21 from allmydata.util.encodingutil import unicode_to_output, quote_output, is_printable_ascii, to_bytes 13 22 14 def l ist(options):23 def ls(options): 15 24 nodeurl = options['node-url'] 16 25 aliases = options.aliases … … 29 38 return 1 30 39 31 path = unicode(path, "utf-8")40 path = str(path, "utf-8") 32 41 url = nodeurl + "uri/%s" % url_quote(rootcap) 33 42 if path: … … 51 60 # The webapi server should always output printable ASCII. 52 61 if is_printable_ascii(data): 53 data = unicode(data, "ascii")62 data = str(data, "ascii") 54 63 print(data, file=stdout) 55 64 return 0 … … 88 97 for name in childnames: 89 98 child = children[name] 90 name = unicode(name)99 name = str(name) 91 100 childtype = child[0] 92 101 … … 148 157 classify = "" 149 158 150 encoding_error = False 151 try: 152 line.append(unicode_to_output(name) + classify) 153 except UnicodeEncodeError: 154 encoding_error = True 155 line.append(quote_output(name) + classify) 159 line.append(name + classify) 156 160 157 161 if options["uri"]: 158 line.append(ensure_ str(uri))162 line.append(ensure_text(uri)) 159 163 if options["readonly-uri"]: 160 line.append(quote_output(ensure_ str(ro_uri) or "-", quotemarks=False))161 162 rows.append( (encoding_error, line))164 line.append(quote_output(ensure_text(ro_uri) or "-", quotemarks=False)) 165 166 rows.append(line) 163 167 164 168 max_widths = [] 165 169 left_justifys = [] 166 for (encoding_error, row)in rows:170 for row in rows: 167 171 for i,cell in enumerate(row): 168 172 while len(max_widths) <= i: … … 186 190 187 191 rc = 0 188 for (encoding_error, row) in rows: 192 for row in rows: 193 row = (fmt % tuple(row)).rstrip() 194 encoding_error = False 195 try: 196 row = unicode_to_output(row) 197 except UnicodeEncodeError: 198 encoding_error = True 199 row = quote_output(row) 189 200 if encoding_error: 190 print( (fmt % tuple(row)).rstrip(), file=stderr)201 print(row, file=stderr) 191 202 rc = 1 192 203 else: 193 print( (fmt % tuple(row)).rstrip(), file=stdout)204 print(row, file=stdout) 194 205 195 206 if rc == 1: -
TabularUnified src/allmydata/scripts/tahoe_manifest.py ¶
r336ca45c r9ed0cd42 1 """ 2 Ported to Python 3. 3 """ 4 from __future__ import unicode_literals 5 from __future__ import absolute_import 6 from __future__ import division 1 7 from __future__ import print_function 2 8 3 from future.utils import PY3 4 from past.builtins import unicode 9 from future.utils import PY2, PY3 10 if PY2: 11 from future.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 12 13 from six import ensure_str 5 14 6 15 from urllib.parse import quote as url_quote … … 38 47 e.display(stderr) 39 48 return 1 40 path = unicode(path, "utf-8")49 path = str(path, "utf-8") 41 50 if path == '/': 42 51 path = '' … … 97 106 print(quote_output(vc, quotemarks=False), file=stdout) 98 107 else: 99 print("%s %s" % (quote_output(d["cap"], quotemarks=False), 100 quote_path(d["path"], quotemarks=False)), file=stdout) 108 # ensure_str() only necessary for Python 2. 109 print(ensure_str("%s %s") % ( 110 quote_output(d["cap"], quotemarks=False), 111 quote_path(d["path"], quotemarks=False)), file=stdout) 101 112 102 113 def manifest(options): -
TabularUnified src/allmydata/util/_python3.py ¶
r336ca45c r9ed0cd42 106 106 "allmydata.scripts.tahoe_backup", 107 107 "allmydata.scripts.tahoe_check", 108 "allmydata.scripts.tahoe_cp", 109 "allmydata.scripts.tahoe_get", 110 "allmydata.scripts.tahoe_invite", 111 "allmydata.scripts.tahoe_ls", 112 "allmydata.scripts.tahoe_manifest", 108 113 "allmydata.scripts.types_", 109 114 "allmydata.stats",
Note: See TracChangeset
for help on using the changeset viewer.