mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-12-02 00:51:41 +00:00
Added dummy diskimage to allow writing assembled files to local disk
This commit is contained in:
parent
e4ce309bd3
commit
dff073208f
@ -23,6 +23,7 @@ from .cartridge import A8CartHeader, AtariCartImage
|
|||||||
from .parsers import SegmentParser, DefaultSegmentParser, guess_parser_for_mime, guess_parser_for_system, guess_container, iter_parsers, iter_known_segment_parsers, mime_parse_order, parsers_for_filename
|
from .parsers import SegmentParser, DefaultSegmentParser, guess_parser_for_mime, guess_parser_for_system, guess_container, iter_parsers, iter_known_segment_parsers, mime_parse_order, parsers_for_filename
|
||||||
from .magic import guess_detail_for_mime
|
from .magic import guess_detail_for_mime
|
||||||
from .utils import to_numpy, text_to_int
|
from .utils import to_numpy, text_to_int
|
||||||
|
from .dummy import LocalFilesystem
|
||||||
|
|
||||||
|
|
||||||
def process(image, dirent, options):
|
def process(image, dirent, options):
|
||||||
@ -54,6 +55,9 @@ def process(image, dirent, options):
|
|||||||
|
|
||||||
|
|
||||||
def find_diskimage(filename):
|
def find_diskimage(filename):
|
||||||
|
if filename == ".":
|
||||||
|
parser = LocalFilesystem()
|
||||||
|
else:
|
||||||
with open(filename, "rb") as fh:
|
with open(filename, "rb") as fh:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print("Loading file %s" % filename)
|
print("Loading file %s" % filename)
|
||||||
|
41
atrcopy/dummy.py
Normal file
41
atrcopy/dummy.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from . import errors
|
||||||
|
from .segments import SegmentData, EmptySegment, ObjSegment
|
||||||
|
from .diskimages import DiskImageBase
|
||||||
|
from .utils import to_numpy
|
||||||
|
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class LocalFilesystemImage(DiskImageBase):
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
|
||||||
|
def __str__(self, path="."):
|
||||||
|
return f"Local filesystem output to: {self.path}"
|
||||||
|
|
||||||
|
def save(self, filename=""):
|
||||||
|
# This is to save the disk image containing the files on the disk image
|
||||||
|
# to the local disk, which doesn't make sense when the disk image is
|
||||||
|
# the filesystem.
|
||||||
|
pass
|
||||||
|
|
||||||
|
def find_dirent(self, name):
|
||||||
|
path = os.path.join(self.path, name)
|
||||||
|
if os.path.exists(path):
|
||||||
|
return True
|
||||||
|
raise errors.FileNotFound("%s not found on disk" % str(name))
|
||||||
|
|
||||||
|
def write_file(self, name, filetype, data):
|
||||||
|
path = os.path.join(self.path, name)
|
||||||
|
with open(path, "wb") as fh:
|
||||||
|
fh.write(data)
|
||||||
|
|
||||||
|
|
||||||
|
class LocalFilesystem():
|
||||||
|
def __init__(self, path="."):
|
||||||
|
self.image = LocalFilesystemImage(path)
|
Loading…
Reference in New Issue
Block a user