# Path: DnD/modules/lib/helpers.py
# def sanitize_filename(name: str) -> str:
#     """Translates problematic characters in a filename into happier ones."""
#     return name.translate(str.maketrans(" '/:", "_@&$"))
# 
# Path: DnD/modules/lib/interface.py
# class JsonInterface(DataInterface):
#     OBJECTSPATH = Path('./objects/')
#     EXTANT = {}
# 
#     def __new__(cls, filename, **kwargs):
#         if kwargs.get('isabsolute', False):
#             totalpath = filename
#         else:
#             totalpath = cls.OBJECTSPATH / filename
#         if totalpath in cls.EXTANT:
#             return cls.EXTANT[totalpath]
#         else:
#             obj = super().__new__(cls)
#             return obj
# 
#     def __init__(self, filename, readonly=False, isabsolute=False):
#         self.shortFilename = h.readable_filename(str(filename))
#         if isabsolute:
#             self.filename = Path(filename)
#         else:
#             self.filename = self.OBJECTSPATH / filename
#         with self.filename.open('r') as f:
#             data = json.load(f, object_pairs_hook=collections.OrderedDict)
#             super().__init__(data, readonly)
#         self.EXTANT[self.filename] = self
# 
#     def __add__(self, other):
#         if isinstance(other, JsonInterface):
#             return LinkedInterface(self, other)
#         elif isinstance(other, LinkedInterface):
#             return other.__add__(self)
#         else:
#             raise TypeError("You can only add a JsonInterface or a "
#                             "MultiInterface to a JsonInterface")
# 
#     def __repr__(self):
#         return "<JsonInterface to {}>".format(self.filename)
# 
#     def __str__(self):
#         return self.shortFilename
# 
#     def write(self):
#         if self.readonly:
#             raise ex.ReadonlyError("Trying to write a readonly file")
#         with open(self.filename, 'w') as f:
#             json.dump(self.data, f, indent=2)


from .helpers import sanitize_filename
from .interface import JsonInterface


class Item:
    def __init__(self, name: str, spec: dict):
        types = spec['type'].split()
        fmt = '{}/{}.{}'

# Path: DnD/modules/lib/helpers.py
# def sanitize_filename(name: str) -> str:
#     """Translates problematic characters in a filename into happier ones."""
#     return name.translate(str.maketrans(" '/:", "_@&$"))
# 
# Path: DnD/modules/lib/interface.py
# class JsonInterface(DataInterface):
#     OBJECTSPATH = Path('./objects/')
#     EXTANT = {}
# 
#     def __new__(cls, filename, **kwargs):
#         if kwargs.get('isabsolute', False):
#             totalpath = filename
#         else:
#             totalpath = cls.OBJECTSPATH / filename
#         if totalpath in cls.EXTANT:
#             return cls.EXTANT[totalpath]
#         else:
#             obj = super().__new__(cls)
#             return obj
# 
#     def __init__(self, filename, readonly=False, isabsolute=False):
#         self.shortFilename = h.readable_filename(str(filename))
#         if isabsolute:
#             self.filename = Path(filename)
#         else:
#             self.filename = self.OBJECTSPATH / filename
#         with self.filename.open('r') as f:
#             data = json.load(f, object_pairs_hook=collections.OrderedDict)
#             super().__init__(data, readonly)
#         self.EXTANT[self.filename] = self
# 
#     def __add__(self, other):
#         if isinstance(other, JsonInterface):
#             return LinkedInterface(self, other)
#         elif isinstance(other, LinkedInterface):
#             return other.__add__(self)
#         else:
#             raise TypeError("You can only add a JsonInterface or a "
#                             "MultiInterface to a JsonInterface")
# 
#     def __repr__(self):
#         return "<JsonInterface to {}>".format(self.filename)
# 
#     def __str__(self):
#         return self.shortFilename
# 
#     def write(self):
#         if self.readonly:
#             raise ex.ReadonlyError("Trying to write a readonly file")
#         with open(self.filename, 'w') as f:
#             json.dump(self.data, f, indent=2)


# Path: DnD/modules/lib/itemLib.py
from .helpers import sanitize_filename
from .interface import JsonInterface



class Item:
    def __init__(self, name: str, spec: dict):
        types = spec['type'].split()
        fmt = '{}/{}.{}'

        filename = fmt.format(types[-1], sanitize_filename(name), '.'.join(types))