Skip to content

Commit 83347eb

Browse files
committed
make saved link name humanish.
1 parent 149e492 commit 83347eb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ccnpy/core/Name.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def is_chunk_id_segment(self):
7474
def is_manifest_id_segment(self):
7575
return self._tlv_type == self.__T_MANIFESTID
7676

77+
7778
class Name(TlvType):
7879
__T_NAME = 0x0000
7980

@@ -115,7 +116,8 @@ def __getitem__(self, index):
115116
return v.decode('UTF-8')
116117

117118
def as_uri(self):
118-
return 'ccnx:/' + '/'.join([f'{c.type()}={c.value()}' for c in self._components])
119+
# return 'ccnx:/' + '/'.join([f'{c.type()}={repr(c.value())}' for c in self._components])
120+
return 'ccnx:/' + '/'.join([repr(c) for c in self._components])
119121

120122
def append(self, component: NameComponent):
121123
"""

ccnpy/flic/tree/TreeIO.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from array import array
1919
from pathlib import PurePath, Path
2020
from typing import Optional, Dict
21+
from urllib.parse import urlparse
2122

2223
from .SizedPointer import SizedPointer
2324
from ..tlvs.Locators import Locators
@@ -38,8 +39,12 @@ class TreeIO:
3839

3940
@staticmethod
4041
def get_link_name(name: Name) -> str:
41-
name_bytes = name.serialize().tobytes()
42-
return f'{name_bytes.hex()}.link'
42+
url = urlparse(name.as_uri())
43+
filename = url.path
44+
safename=filename.replace('/','~')
45+
return f'{safename}.link'
46+
# name_bytes = name.serialize().tobytes()
47+
# return f'{name_bytes.hex()}.link'
4348

4449
class DataBuffer:
4550
def __init__(self):

0 commit comments

Comments
 (0)