MythTV master
xbmcvfs.py
Go to the documentation of this file.
1# Tiny portion of Kodistubs to translate CU LRC to MythTV. If CU LRC
2# ever refers to other functions, simply copy them in here from
3# original Kodistubs and update where needed like below.
4
5from typing import Union, Optional
6import os.path
7
8# embedlrc.py and musixmatchlrc.py need some File access
9
10class File:
11
12 def __init__(self, filepath: str, mode: Optional[str] = None) -> None:
13 self.filename = filepath
14 if mode:
15 self.fh = open(filepath, mode)
16 else:
17 self.fh = open(filepath, "rb")
18
19 def __enter__(self) -> 'File': # Required for context manager
20 return self
21
22 def __exit__(self, exc_type, exc_val, exc_tb): # Required for context manager
23 pass
24
25 def read(self, numBytes: int = 0) -> str:
26 if numBytes:
27 return self.fh.read(numBytes)
28 return self.fh.read()
29
30 def readBytes(self, numBytes: int = 0) -> bytearray:
31 if numBytes:
32 return bytearray(self.fh.read(numBytes))
33 return bytearray(self.fh.read())
34
35 def write(self, buffer: Union[str, bytes, bytearray]) -> bool:
36 return self.fh.write(buffer)
37
38 def size(self) -> int:
39 return 0
40
41 def seek(self, seekBytes: int, iWhence: int = 0) -> int:
42 return self.fh.seek(seekBytes, iWhence);
43
44 def tell(self) -> int:
45 return self.fh.tell()
46
47 def close(self) -> None:
48 self.fh.close()
49 pass
50
51def exists(path: str) -> bool:
52 # for musixmatchlrc.py the test must work or return False
53 return os.path.isfile(path)
54
55def translatePath(path: str) -> str:
56 return ""
None close(self)
Definition: xbmcvfs.py:47
str read(self, int numBytes=0)
Definition: xbmcvfs.py:25
None __init__(self, str filepath, Optional[str] mode=None)
Definition: xbmcvfs.py:12
'File' __enter__(self)
Definition: xbmcvfs.py:19
int seek(self, int seekBytes, int iWhence=0)
Definition: xbmcvfs.py:41
int tell(self)
Definition: xbmcvfs.py:44
bool write(self, Union[str, bytes, bytearray] buffer)
Definition: xbmcvfs.py:35
int size(self)
Definition: xbmcvfs.py:38
bytearray readBytes(self, int numBytes=0)
Definition: xbmcvfs.py:30
def __exit__(self, exc_type, exc_val, exc_tb)
Definition: xbmcvfs.py:22
str translatePath(str path)
Definition: xbmcvfs.py:55
bool exists(str path)
Definition: xbmcvfs.py:51