mirror of https://github.com/iKarith/cppo-ng.git
Style cleanup to diskimg.py
This is still a good ways from "proper" because this code is still kinda not really done.
This commit is contained in:
parent
7c169b2053
commit
b55ea886c1
|
@ -16,20 +16,28 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
"""Disk image functions
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import struct
|
|
||||||
from .buffer.bytebuffer import ByteBuffer
|
from .buffer.bytebuffer import ByteBuffer
|
||||||
|
|
||||||
# FIXME Move to_sys_name
|
# FIXME Move to_sys_name
|
||||||
from . import legacy
|
from . import legacy
|
||||||
|
|
||||||
class Disk:
|
class Disk:
|
||||||
def __init__(self, name=None):
|
"""A basic "intelligent" (hopefully at some point) disk image class
|
||||||
|
"""
|
||||||
|
def __init__(self, name: str = None) -> None:
|
||||||
if name is not None:
|
if name is not None:
|
||||||
self.pathname = name
|
self.pathname = name
|
||||||
self.path, self.filename = os.path.split(name)
|
self.path, self.filename = os.path.split(name)
|
||||||
self.diskname, self.ext = os.path.splitext(self.filename)
|
self.diskname, self.ext = os.path.splitext(self.filename)
|
||||||
self.ext = os.path.splitext(name)[1].lower()
|
self.ext = os.path.splitext(name)[1].lower()
|
||||||
# FIXME: Handle compressed images?
|
# FIXME: Handle compressed images?
|
||||||
with open(legacy.to_sys_name(name), "rb") as f:
|
with open(legacy.to_sys_name(name), "rb") as imagefile:
|
||||||
self.buffer = ByteBuffer(f.read())
|
self.buffer = ByteBuffer(imagefile.read())
|
||||||
|
|
||||||
|
def __len__(self) -> int:
|
||||||
|
"""Implement len(self)"""
|
||||||
|
return len(self.buffer)
|
||||||
|
|
Loading…
Reference in New Issue